Inheritance: MonoBehaviour
    void OnEnable()
    {
        sceneMode = SceneMode.Edit;
        script = target as WaypointManager;

        if (script == null)
            return;

        if (script.pathList == null) script.pathList = new List<PathData>();
        for (int i = 0; i < script.pathList.Count; i++)
        {
            if (script.pathList[i] == null) script.pathList.RemoveAt(i);
        }

        script.selected = null;
        foreach (var path in script.pathList)
        {
            if (path != null)
            {
                String strAssetPath = AssetDatabase.GetAssetPath(path);
                int startIndex = strAssetPath.LastIndexOf("/") + 1;
                int length = strAssetPath.LastIndexOf(".") - startIndex;
                path.pathName = strAssetPath.Substring(startIndex, length);
            }
        }
    }
Exemple #2
0
    void Awake()
    {
        mInstance = this;

        mWaypoints = new Dictionary<string, List<Transform>>(transform.childCount);

        //generate waypoints based on their names
        foreach(Transform child in transform) {
            List<Transform> points;

            if(child.childCount > 0) {
                points = new List<Transform>(child.childCount);
                foreach(Transform t in child) {
                    points.Add(t);
                }
                points.Sort(delegate(Transform t1, Transform t2) {
                    return t1.name.CompareTo(t2.name);
                });
            }
            else {
                points = new List<Transform>(1);
                points.Add(child);
            }

            mWaypoints.Add(child.name, points);
        }
    }
 //public WaypointScript RightWaypoint;
 void Awake()
 {
     if (Instance == null)
         Instance = this;
     else if (Instance != this)
         Destroy(gameObject);
 }
	protected void Awake()
	{		
		waypointManager = GameObject.Find("WaypointManager").GetComponent<WaypointManager>();
		waypointManager.SubscribeToAssignedWaypointEvent(this.gameObject, SetWaypoint);
		
		myBehaviorManager.OnBehaviorStateChangedEvent += HandleOnBehaviorStateChangedEvent;
		
		myEntityComponent = GetComponent<HeroComponent>();
		performingActions = false;
		movingToEntity = false;
	}
    public override void OnInspectorGUI()
    {
        manager = (WaypointManager)target;

        Waypoint[] wpm = manager.GetComponentsInChildren<Waypoint>();
        foreach (Waypoint wp in wpm)
        {
            manager.hasBreakpoint = (wp.WPType == Waypoint.TypeList.Breakpoint) ? true : false ;
        }
        EditorGUILayout.HelpBox ("This waypoint has a breakpoint :" + manager.hasBreakpoint, MessageType.Info);
        base.OnInspectorGUI();
    }
 // Use this for initialization
 public void Setup(LevelManager _levMan)
 {
     _lm = _levMan;
     WaypointManager[] waypointsManagers = GetComponentsInChildren<WaypointManager>();
     foreach (WaypointManager wpm in waypointsManagers)
     {
         waypointsMan.Add(wpm);
         wpm.Setup(_lm);
     }
     _DraculaListSpawnBeforeSendingLetter = waypointsMan[0];
     _DraculaListSpawnBeforeSaving = waypointsMan[1];
 }
	// Use this for initialization
	public override void Start() 
    {
        waypointManager = GameObject.Find("WaypointManager").GetComponent<WaypointManager>();

        if (waypointManager != null)
        {
            waypointManager.SubscribeToAssignedWaypointEvent(this.gameObject, SetWaypoint);
            CurrWaypoint = waypointManager.GetWaypoint(this.gameObject);
            this.target = CurrWaypoint.transform;
        }

        base.Start();
	}
        void Start()
        {
            DontDestroyOnLoad(this);

            if (!initialized)
            {
                // Log version info
                var ainfoV = Attribute.GetCustomAttribute(typeof(WaypointManager).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
                Debug.Log("WaypointManager " + ainfoV.InformationalVersion + " loading...");

                LoadTextures();
                LoadConfiguration();
                LoadToolbar();

                GameEvents.onGUIApplicationLauncherReady.Add(new EventVoid.OnEvent(SetupToolbar));
                GameEvents.onGUIApplicationLauncherUnreadifying.Add(new EventData<GameScenes>.OnEvent(TeardownToolbar));
                GameEvents.onGameSceneLoadRequested.Add(new EventData<GameScenes>.OnEvent(OnGameSceneLoad));
                GameEvents.onHideUI.Add(new EventVoid.OnEvent(OnHideUI));
                GameEvents.onShowUI.Add(new EventVoid.OnEvent(OnShowUI));
                GameEvents.onPlanetariumTargetChanged.Add(new EventData<MapObject>.OnEvent(PlanetariumTargetChanged));

                Config.Load();

                Debug.Log("WaypointManager " + ainfoV.InformationalVersion + " loaded.");

                Instance = this;
                initialized = true;
            }
            else
            {
                DestroyImmediate(this);
            }
        }
Exemple #9
0
 // Use this for initialization
 void Start()
 {
     m_waypointManager = GetComponent <WaypointManager>();
     StartCoroutine(Spawn());
 }
Exemple #10
0
    protected override GameObject createTile(Tile.TILE_TYPE type, Vector3 pos, Vector3 size)
    {
        if (type == Tile.TILE_TYPE.TILE_EMPTY || type >= Tile.TILE_TYPE.NUM_TILE)
        {
            return(null);
        }
        if (!tileBlueprints[(int)type])
        {
            return(null);
        }

        GameObject      tile               = null;
        float           scaleRatio         = tileBlueprints[(int)type].GetComponent <Tile>().ScaleRatio;
        WaypointManager refWaypointManager = this.transform.root.gameObject.GetComponentInChildren <WaypointManager>();
        EnemyManager    enemyManager       = RefEnemyManager.GetComponent <EnemyManager>();

        switch (type)
        {
        // TODO: Add special case for tile creation like enemy
        case Tile.TILE_TYPE.TILE_ENEMY:
        {
            // Create enemy
            GameObject enemy = RefEnemyManager.Fetch();
            if (enemy)
            {
                // Set enemy data
                Vector3 enemyPos = pos + new Vector3((scaleRatio - 1) * tileSize * 0.5f, -((scaleRatio - 1) * tileSize * 0.5f));
                enemyPos.z = 1.0f;
                Vector3 enemySize = size * scaleRatio;
                enemy.SetActive(true);

                // Get a handle to the Enemy component
                var enemyComponent = enemy.GetComponent <Enemy.Enemy>();
                if (enemyComponent)
                {
                    enemyComponent.Init(enemyPos, refWaypointManager, playerList, enemyManager);
                }
                enemy.transform.localScale = enemySize;
            }
        }
        break;

        case Tile.TILE_TYPE.TILE_WAYPOINT:
        {
            if (refWaypointManager)
            {
                // Create waypoint
                GameObject waypoint    = Instantiate(tileBlueprints[(int)type]);
                Vector3    waypointPos = pos + new Vector3((scaleRatio - 1) * tileSize * 0.5f, -((scaleRatio - 1) * tileSize * 0.5f));
                waypointPos.z = 1.5f;
                Vector3 waypointSize = size * scaleRatio;
                waypoint.transform.position   = waypointPos;
                waypoint.transform.localScale = waypointSize;
                refWaypointManager.Add(waypoint.GetComponent <Waypoint>());
            }
        }
        break;

        case Tile.TILE_TYPE.TILE_FIRST_PLAYER:
        {
            Vector3 playerPos  = pos + new Vector3((scaleRatio - 1) * tileSize * 0.5f, -((scaleRatio - 1) * tileSize * 0.5f));
            Vector3 playerSize = size * scaleRatio;
            playerPos.z = 0.0f;
            RefPlayer1.transform.position   = playerPos;
            RefPlayer1.transform.localScale = playerSize;
        }
        break;

        case Tile.TILE_TYPE.TILE_SECOND_PLAYER:
        {
            Vector3 playerPos  = pos + new Vector3((scaleRatio - 1) * tileSize * 0.5f, -((scaleRatio - 1) * tileSize * 0.5f));
            Vector3 playerSize = size * scaleRatio;
            playerPos.z = 0.0f;
            RefPlayer2.transform.position   = playerPos;
            RefPlayer2.transform.localScale = playerSize;
        }
        break;

        case Tile.TILE_TYPE.TILE_COIN:
        {
            tile = Instantiate(tileBlueprints[(int)type]);

            if (tile.GetComponent <Item>() != null || type == Tile.TILE_TYPE.TILE_SPIKE_TRAP || type == Tile.TILE_TYPE.TILE_CANNON)
            {
                pos.z -= 1;
                tile.SetActive(true);
            }
            else
            {
                tile.SetActive(true);
            }

            // Set data for each tile
            tile.transform.position            = pos + new Vector3((scaleRatio - 1) * tileSize * 0.5f, -((scaleRatio - 1) * tileSize * 0.5f));
            tile.transform.localScale          = size * scaleRatio;
            tile.transform.parent              = this.transform;
            tile.GetComponent <Coin>().Manager = transform.root.gameObject.GetComponent <GameManager>();
        }
        break;

        case Tile.TILE_TYPE.TILE_EXIT:
        {
            tile = Instantiate(tileBlueprints[(int)type]);

            if (tile.GetComponent <Item>() != null || type == Tile.TILE_TYPE.TILE_SPIKE_TRAP || type == Tile.TILE_TYPE.TILE_CANNON)
            {
                pos.z -= 1;
                tile.SetActive(true);
            }
            else
            {
                tile.SetActive(true);
            }

            // Set data for each tile
            tile.transform.position            = pos + new Vector3((scaleRatio - 1) * tileSize * 0.5f, -((scaleRatio - 1) * tileSize * 0.5f));
            tile.transform.localScale          = size * scaleRatio;
            tile.transform.parent              = this.transform;
            tile.GetComponent <Exit>().Manager = transform.root.gameObject.GetComponent <GameManager>();
        }
        break;

        default:
        {
            tile = Instantiate(tileBlueprints[(int)type]);

            if (tile.GetComponent <Item>() != null || type == Tile.TILE_TYPE.TILE_SPIKE_TRAP || type == Tile.TILE_TYPE.TILE_CANNON)
            {
                pos.z -= 1;
                tile.SetActive(true);
            }
            else
            {
                tile.SetActive(true);
            }

            // Set data for each tile
            tile.transform.position   = pos + new Vector3((scaleRatio - 1) * tileSize * 0.5f, -((scaleRatio - 1) * tileSize * 0.5f));
            tile.transform.localScale = size * scaleRatio;
            tile.transform.parent     = this.transform;
        }
        break;
        }
        return(tile);
    }
 public FollowPathToRandomAction(Transform character,
                                 float speed, LayerMask obstacleMask,
                                 WaypointManager waypointManager, MovementHandler movementHandler)
     : base(character, speed, obstacleMask, waypointManager, movementHandler)
 {
 }
Exemple #12
0
 void OnDestroy()
 {
     mInstance = null;
     mWaypoints.Clear();
 }
Exemple #13
0
        public void Save()
        {
            string profileDir = Config.GetUserDirectory("Profiles");
            string file       = Path.Combine(profileDir, $"{m_Name}.xml");

            if (m_Name != "default" && !m_Warned)
            {
                try
                {
                    m_Mutex = new System.Threading.Mutex(true, $"Razor_Profile_{m_Name}");

                    if (!m_Mutex.WaitOne(10, false))
                    {
                        throw new Exception("Can't grab profile mutex, must be in use!");
                    }
                }
                catch
                {
                    //MessageBox.Show( Engine.ActiveWindow, Language.Format( LocString.ProfileInUse, m_Name ), "Profile In Use", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                    //m_Warned = true;
                    return; // refuse to overwrite profiles that we don't own.
                }
            }

            XmlTextWriter xml;

            try
            {
                xml = new XmlTextWriter(file, Encoding.UTF8);
            }
            catch
            {
                return;
            }

            xml.Formatting  = Formatting.Indented;
            xml.IndentChar  = '\t';
            xml.Indentation = 1;

            xml.WriteStartDocument(true);
            xml.WriteStartElement("profile");

            foreach (KeyValuePair <string, object> de in m_Props)
            {
                xml.WriteStartElement("property");
                xml.WriteAttributeString("name", de.Key);
                if (de.Value == null)
                {
                    xml.WriteAttributeString("type", "-null-");
                }
                else
                {
                    xml.WriteAttributeString("type", de.Value.GetType().FullName);
                    xml.WriteString(de.Value.ToString());
                }

                xml.WriteEndElement();
            }

            xml.WriteStartElement("filters");
            Filter.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("counters");
            Counter.SaveProfile(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("agents");
            Agent.SaveProfile(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("dresslists");
            DressList.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("hotkeys");
            HotKey.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("passwords");
            PasswordMemory.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("overheadmessages");
            OverheadManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("containerlabels");
            ContainerLabels.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("macrovariables");
            MacroVariables.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("scriptvariables");
            ScriptVariables.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("friends");
            FriendsManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("textfilters");
            TextFilterManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("targetfilters");
            TargetFilterManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("soundfilters");
            SoundMusicManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("waypoints");
            WaypointManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteEndElement(); // end profile section

            xml.Close();
        }
Exemple #14
0
 void Start()
 {
     WaypointManager.RegisterWaypoint(this);
     Position = transform.position;
 }
Exemple #15
0
    //--------- this short example visualizes: ---------\\
    //*instantiate a walker object and a path at runtime
    //*add path reference to our WaypointManager so other have access to it
    //*set path container of this object and start moving
    //*reposition path (walker object automatically gets new waypoint positions)
    //*stop movement
    //*continue movement
    void Example1()
    {
        GUI.Label(new Rect(10, 5, 120, 30), "Example 1");

        if (!walkerObj1 && GUI.Button(new Rect(10, 30, 130, 25), "Instantiate Objects"))
        {
            //instantiate walker prefab
            walkerObj1      = (GameObject)Instantiate(walkerPrefab, position1.position, Quaternion.identity);
            walkerObj1.name = "Soldier@" + System.DateTime.Now.TimeOfDay;
            //instantiate path prefab
            newPath1 = (GameObject)Instantiate(pathPrefab, position1.position, Quaternion.identity);
            //rename the path to ensure it is unique
            newPath1.name = "RuntimePath@" + System.DateTime.Now.TimeOfDay;

            //add newly instantiated path to the WaypointManager dictionary
            WaypointManager.AddPath(newPath1);
        }


        if (walkerObj1 && !walkeriM1 && GUI.Button(new Rect(140, 30, 130, 25), "Start Movement"))
        {
            //get iMove component of this walker object, here we cahce it once
            walkeriM1 = walkerObj1.GetComponent <iMove>();
            //set path container to path instantiated above - access WaypointManager dictionary
            //and start movement on new path
            walkeriM1.SetPath(WaypointManager.Paths[newPath1.name]);
        }


        //change instantiated path position from position1 to position2 or vice versa
        if (newPath1 && GUI.Button(new Rect(10, 30, 130, 25), "Reposition Path"))
        {
            Transform path = newPath1.transform;

            if (path.position == position1.position)
            {
                path.position = position2.position;
            }
            else
            {
                path.position = position1.position;
            }
        }


        //stop and reset movement to the first waypoint
        if (walkerObj1 && walkeriM1 && GUI.Button(new Rect(140, 30, 130, 25), "Reset Walker"))
        {
            walkeriM1.Reset();
            walkeriM1 = null;
        }


        //stop any movement for the time being
        if (walkerObj1 && walkeriM1 && GUI.Button(new Rect(270, 30, 100, 25), "Stop Walker"))
        {
            walkeriM1.Stop();

            //don't call this method in hoMove if you want to resume the animation later,
            //call .Pause() and .Resume() instead
        }


        //continue movement
        if (walkerObj1 && walkeriM1 && GUI.Button(new Rect(370, 30, 100, 25), "Continue Walk"))
        {
            //set moveToPath boolean of instantiated walker to true,
            //so on calling StartMove() it does not appear at the next waypoint but walks to it instead
            walkeriM1.moveToPath = true;
            //continue movement
            walkeriM1.StartMove();
        }
    }
Exemple #16
0
        protected override void OnOffered()
        {
            System.Random random = new System.Random(contract.MissionSeed);

            int index = 0;

            foreach (WaypointData wpData in waypoints)
            {
                // Do type-specific waypoint handling
                if (wpData.type == "RANDOM_WAYPOINT")
                {
                    // Generate the position
                    WaypointManager.ChooseRandomPosition(out wpData.waypoint.latitude, out wpData.waypoint.longitude,
                                                         wpData.waypoint.celestialName, wpData.waterAllowed, wpData.forceEquatorial, random);
                }
                else if (wpData.type == "RANDOM_WAYPOINT_NEAR")
                {
                    CelestialBody body         = FlightGlobals.Bodies.Where(b => b.name == wpData.waypoint.celestialName).First();
                    Waypoint      nearWaypoint = waypoints[wpData.nearIndex].waypoint;
                    // TODO - this is really bad, we need to implement this method ourselves...
                    do
                    {
                        WaypointManager.ChooseRandomPositionNear(out wpData.waypoint.latitude, out wpData.waypoint.longitude,
                                                                 nearWaypoint.latitude, nearWaypoint.longitude, wpData.waypoint.celestialName,
                                                                 wpData.maxDistance, wpData.waterAllowed, random);
                    } while (WaypointUtil.GetDistance(wpData.waypoint.latitude, wpData.waypoint.longitude, nearWaypoint.latitude, nearWaypoint.longitude,
                                                      body.Radius) < wpData.minDistance);
                }
                else if (wpData.type == "PQS_CITY")
                {
                    CelestialBody body     = FlightGlobals.Bodies.Where(b => b.name == wpData.waypoint.celestialName).First();
                    Vector3d      position = wpData.pqsCity.transform.position;

                    // Translate by the PQS offset (inverse transform of coordinate system)
                    Vector3d v         = wpData.pqsOffset;
                    Vector3d i         = wpData.pqsCity.transform.right;
                    Vector3d j         = wpData.pqsCity.transform.forward;
                    Vector3d k         = wpData.pqsCity.transform.up;
                    Vector3d offsetPos = new Vector3d(
                        (j.y * k.z - j.z * k.y) * v.x + (i.z * k.y - i.y * k.z) * v.y + (i.y * j.z - i.z * j.y) * v.z,
                        (j.z * k.x - j.x * k.z) * v.x + (i.x * k.z - i.z * k.x) * v.y + (i.z * j.x - i.x * j.z) * v.z,
                        (j.x * k.y - j.y * k.x) * v.x + (i.y * k.x - i.x * k.y) * v.y + (i.x * j.y - i.y * j.x) * v.z
                        );
                    offsetPos *= (i.x * j.y * k.z) + (i.y * j.z * k.x) + (i.z * j.x * k.y) - (i.z * j.y * k.x) - (i.y * j.x * k.z) - (i.x * j.z * k.y);
                    wpData.waypoint.latitude  = body.GetLatitude(position + offsetPos);
                    wpData.waypoint.longitude = body.GetLongitude(position + offsetPos);
                }

                // Set altitude
                if (wpData.randomAltitude)
                {
                    CelestialBody body = FlightGlobals.Bodies.Where <CelestialBody>(b => b.name == wpData.waypoint.celestialName).First();
                    if (body.atmosphere)
                    {
                        wpData.waypoint.altitude = random.NextDouble() * (body.atmosphereDepth);
                    }
                    else
                    {
                        wpData.waypoint.altitude = 0.0;
                    }
                }

                // Set name
                if (string.IsNullOrEmpty(wpData.waypoint.name))
                {
                    CelestialBody body = FlightGlobals.Bodies.Where <CelestialBody>(b => b.name == wpData.waypoint.celestialName).First();
                    wpData.waypoint.name = StringUtilities.GenerateSiteName(contract.MissionSeed + index++, body, !wpData.waterAllowed);
                }

                if (!wpData.hidden && (string.IsNullOrEmpty(wpData.parameter) || contract.AllParameters.
                                       Where(p => p.ID == wpData.parameter && p.State == ParameterState.Complete).Any()))
                {
                    AddWayPoint(wpData.waypoint);
                }
            }
        }
Exemple #17
0
 public void findClosestWp()
 {
     foreach (Waypoint wp in _levman.wpList)
     {
         float distWpDracula = Vector3.Distance(transform.position, wp.transform.position);
         wp.distWP = distWpDracula;
     }
     _levman.wpList.Sort(delegate (Waypoint x, Waypoint y)
       	{
         if (x.distWP < y.distWP) return -1;
         if (x.distWP > y.distWP) return 1;
         else return 0;
     });
     currWp = _levman.wpList[0];
     currWPM = currWp.linkedManager;
 }
Exemple #18
0
 private void randomSpawn()
 {
     if (State != StateList.Chasing && _levman.Hours.currentTime == HoursManager.DayTime.Day)
     {
         currWPM = _levman.pathDirector.waypointsMan[0];
         switch (_levman.Diff)
         {
         case LevelManager.DifficultyState.BeforeLetter :
         {
             print ("spawn" + _levman.Diff);
             currWPM = _levman.pathDirector._DraculaListSpawnBeforeSendingLetter;
             break;
         }
         case LevelManager.DifficultyState.WaitingSave :
         {
             currWPM = _levman.pathDirector._DraculaListSpawnBeforeSaving;
             break;
         }
         }
     //			print ("spawn");
         Waypoint _WP = currWPM.pickRandomWP();
         currWp = currWPM.pickRandomWP();
         pouf.transform.parent.transform.position = _WP.transform.position;
         pouf.alpha = 1f;
         pouf.PlayOnce("pouf");
         StartCoroutine(doAppear(_WP));
         new OTTween(spr, 0.01f).Tween("alpha", 0f);
         new OTTween(transform, 0.1f).Tween("position", currWp.transform.position);
         new OTTween(spr, 0.03f).Tween("alpha", 1f);
     //			transform.position = currWp.transform.position;
     }
 }
 void Awake()
 {
     Instance = this;
 }
    public HeroParty()
    {
        heroQueue.onLeaderChanged += LeaderChanged;
		heroQueue.onFollowerChanged += FollowerChanged;
        waypointManager = GameObject.Find("WaypointManager").GetComponent<WaypointManager>();
    }
Exemple #21
0
        protected override bool Generate()
        {
            if (AreWingsUnlocked() == false)
            {
                return(false);
            }

            //Allow four contracts in pocket but only two on the board at a time.
            int offeredContracts = 0;
            int activeContracts  = 0;

            foreach (AerialContract contract in ContractSystem.Instance.GetCurrentContracts <AerialContract>())
            {
                if (contract.ContractState == Contract.State.Offered)
                {
                    offeredContracts++;
                }
                else if (contract.ContractState == Contract.State.Active)
                {
                    activeContracts++;
                }
            }

            if (offeredContracts >= 2 || activeContracts >= 4)
            {
                return(false);
            }

            double range = 10000.0;

            System.Random        generator           = new System.Random(this.MissionSeed);
            int                  additionalWaypoints = 0;
            List <CelestialBody> allBodies           = GetBodies_Reached(true, false);
            List <CelestialBody> atmosphereBodies    = new List <CelestialBody>();

            foreach (CelestialBody body in allBodies)
            {
                if (body.atmosphere)
                {
                    atmosphereBodies.Add(body);
                }
            }

            if (atmosphereBodies.Count == 0)
            {
                return(false);
            }

            targetBody = atmosphereBodies[UnityEngine.Random.Range(0, atmosphereBodies.Count)];

            switch (targetBody.GetName())
            {
            case "Jool":
                additionalWaypoints = 0;
                minAltitude         = 15000.0;
                maxAltitude         = 30000.0;
                break;

            case "Duna":
                additionalWaypoints = 1;
                minAltitude         = 8000.0;
                maxAltitude         = 16000.0;
                break;

            case "Laythe":
                additionalWaypoints = 1;
                minAltitude         = 15000.0;
                maxAltitude         = 30000.0;
                break;

            case "Eve":
                additionalWaypoints = 1;
                minAltitude         = 20000.0;
                maxAltitude         = 40000.0;
                break;

            case "Kerbin":
                additionalWaypoints = 2;
                minAltitude         = 12500.0;
                maxAltitude         = 25000.0;
                break;

            default:
                additionalWaypoints = 0;
                minAltitude         = 0.0;
                maxAltitude         = 10000.0;
                break;
            }

            int    waypointCount            = 0;
            double altitudeHalfQuarterRange = Math.Abs(maxAltitude - minAltitude) * 0.125;
            double upperMidAltitude         = ((maxAltitude + minAltitude) / 2.0) + altitudeHalfQuarterRange;
            double lowerMidAltitude         = ((maxAltitude + minAltitude) / 2.0) - altitudeHalfQuarterRange;

            minAltitude = Math.Round((minAltitude + (generator.NextDouble() * (lowerMidAltitude - minAltitude))) / 100.0) * 100.0;
            maxAltitude = Math.Round((upperMidAltitude + (generator.NextDouble() * (maxAltitude - upperMidAltitude))) / 100.0) * 100.0;

            if (this.prestige == Contract.ContractPrestige.Trivial)
            {
                waypointCount  = 1;
                waypointCount += additionalWaypoints;
                range          = 100000.0;
            }
            else if (this.prestige == Contract.ContractPrestige.Significant)
            {
                waypointCount  = 2;
                waypointCount += additionalWaypoints;
                range          = 200000.0;
            }
            else if (this.prestige == Contract.ContractPrestige.Exceptional)
            {
                waypointCount  = 3;
                waypointCount += additionalWaypoints;
                range          = 300000.0;
            }

            WaypointManager.ChooseRandomPosition(out centerLatitude, out centerLongitude, targetBody.GetName(), true);

            for (int x = 0; x < waypointCount; x++)
            {
                ContractParameter newParameter;
                newParameter = this.AddParameter(new FlightWaypointParameter(x, targetBody, minAltitude, maxAltitude, centerLatitude, centerLongitude, range), null);
                newParameter.SetFunds(3750.0f, targetBody);
                newParameter.SetReputation(7.5f, targetBody);
                newParameter.SetScience(7.5f, targetBody);
            }

            base.AddKeywords(new string[] { "surveyflight" });
            base.SetExpiry();
            base.SetDeadlineYears(5.0f, targetBody);
            base.SetFunds(4000.0f, 17500.0f, targetBody);
            base.SetReputation(50.0f, 25.0f, targetBody);
            return(true);
        }
Exemple #22
0
 void Awake()
 {
     Instance = this;
 }
Exemple #23
0
 void Start()
 {
     waypointmanager = GameObject.Find("Waypoint Manager").GetComponent <WaypointManager>();
     shop            = GameObject.Find("Shop").GetComponent <Shop>();
 }
Exemple #24
0
        public bool Load()
        {
            if (m_Name == null || m_Name.Trim() == "")
            {
                return(false);
            }

            string path = Config.GetUserDirectory("Profiles");
            string file = Path.Combine(path, $"{m_Name}.xml");

            if (!File.Exists(file))
            {
                return(false);
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(file);
            }
            catch
            {
                MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileCorrupt, file),
                                "Profile Load Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            XmlElement root = doc["profile"];

            if (root == null)
            {
                return(false);
            }

            Assembly exe = Assembly.GetCallingAssembly();

            if (exe == null)
            {
                return(false);
            }

            foreach (XmlElement el in root.GetElementsByTagName("property"))
            {
                try
                {
                    string name    = el.GetAttribute("name");
                    string typeStr = el.GetAttribute("type");
                    string val     = el.InnerText;

                    if (typeStr == "-null-" || name == "LimitSize" || name == "VisRange")
                    {
                        //m_Props[name] = null;
                        if (m_Props.ContainsKey(name))
                        {
                            m_Props.Remove(name);
                        }
                    }
                    else
                    {
                        Type type = Type.GetType(typeStr);
                        if (type == null)
                        {
                            type = exe.GetType(typeStr);
                        }

                        if (m_Props.ContainsKey(name) || name == "ForceSize")
                        {
                            if (type == null)
                            {
                                m_Props.Remove(name);
                            }
                            else
                            {
                                m_Props[name] = GetObjectFromString(val, type);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileLoadEx, e.ToString()),
                                    "Profile Load Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            Filter.Load(root["filters"]);
            Counter.LoadProfile(root["counters"]);
            Agent.LoadProfile(root["agents"]);
            DressList.Load(root["dresslists"]);
            TargetFilterManager.Load(root["targetfilters"]);
            SoundMusicManager.Load(root["soundfilters"]);
            WaypointManager.Load(root["waypoints"]);
            TextFilterManager.Load(root["textfilters"]);
            FriendsManager.Load(root["friends"]);
            HotKey.Load(root["hotkeys"]);
            PasswordMemory.Load(root["passwords"]);
            OverheadManager.Load(root["overheadmessages"]);
            ContainerLabels.Load(root["containerlabels"]);
            MacroVariables.Load(root["macrovariables"]);
            //imports previous absolutetargets and doubleclickvariables if present in profile
            if ((root.SelectSingleNode("absolutetargets") != null) ||
                (root.SelectSingleNode("doubleclickvariables") != null))
            {
                MacroVariables.Import(root);
            }

            ScriptVariables.Load(root["scriptvariables"]);

            GoldPerHourTimer.Stop();
            DamageTracker.Stop();

            if (m_Props.ContainsKey("ForceSize"))
            {
                try
                {
                    int x, y;
                    switch ((int)m_Props["ForceSize"])
                    {
                    case 1:
                        x = 960;
                        y = 600;
                        break;

                    case 2:
                        x = 1024;
                        y = 768;
                        break;

                    case 3:
                        x = 1152;
                        y = 864;
                        break;

                    case 4:
                        x = 1280;
                        y = 720;
                        break;

                    case 5:
                        x = 1280;
                        y = 768;
                        break;

                    case 6:
                        x = 1280;
                        y = 800;
                        break;

                    case 7:
                        x = 1280;
                        y = 960;
                        break;

                    case 8:
                        x = 1280;
                        y = 1024;
                        break;

                    case 0:
                    default:
                        x = 800;
                        y = 600;
                        break;
                    }

                    SetProperty("ForceSizeX", x);
                    SetProperty("ForceSizeY", y);

                    if (x != 800 || y != 600)
                    {
                        SetProperty("ForceSizeEnabled", true);
                    }

                    m_Props.Remove("ForceSize");
                }
                catch
                {
                }
            }

            //if ( !Language.Load( GetString( "Language" ) ) )
            //	MessageBox.Show( Engine.ActiveWindow, "Warning: Could not load language from profile, using current language instead.", "Language Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );

            return(true);
        }
 public override void OnInit()
 {
     //WaypointManager
     Waypoints = new WaypointManager(Game, Owner, startSegmentId);
 }
Exemple #26
0
    //inspector input
    public override void OnInspectorGUI()
    {
        //show default variables of script "WaypointManager"
        DrawDefaultInspector();
        //get WaypointManager.cs reference
        script = (WaypointManager)target;

        //make the default styles used by EditorGUI look like controls
        EditorGUIUtility.LookLikeControls();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();

        //draw path text label
        GUILayout.Label("Enter Path Name: ", EditorStyles.boldLabel, GUILayout.Height(15));
        //display text field for creating a path with that name
        pathName = EditorGUILayout.TextField(pathName, GUILayout.Height(15));

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();

        //create new path button
        if (GUILayout.Button("Start Path", GUILayout.Height(40)))
        {
            //no path name defined, abort with short editor warning
            if (pathName == "")
            {
                Debug.LogWarning("no path name defined");
                return;
            }

            //path name already given, abort with short editor warning
            if (script.transform.FindChild(pathName) != null)
            {
                Debug.LogWarning("path name already given");
                return;
            }

            //already started a new path, abort further operations, editor warning
            if (placing == true)
            {
                Debug.LogWarning("path already started, use alt + left mouse button to place new waypoints within scene view");
                return;
            }

            //we passed all prior checks, toggle waypoint placing on
            placing = true;
            //create a new container transform which will hold all new waypoints
            path = new GameObject(pathName);
            //attach PathManager.cs component to this new waypoint container
            pathMan = path.AddComponent <PathManager>();
            //create waypoint array instance of PathManager
            pathMan.waypoints = new Transform[0];
            //reset position and parent container gameobject to this manager gameobject
            path.transform.position = script.gameObject.transform.position;
            path.transform.parent   = script.gameObject.transform;
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        //finish path button
        if (GUILayout.Button("Finish Editing", GUILayout.Height(40)))
        {
            //return if no path was started or not enough waypoints, so wpList is empty
            if (wpList.Count < 2)
            {
                Debug.LogWarning("not enough waypoints placed");

                //if we have created a path already, destroy it again
                if (path)
                {
                    DestroyImmediate(path);
                }
            }
            else
            {
                //switch name of last created waypoint to waypointEnd,
                //so we will recognize this path ended (this gets an other editor gizmo)
                wpList[wpList.Count - 1].name = "WaypointEnd";
                //do the same with first waypoint
                wpList[0].name = "WaypointStart";
            }

            //toggle placing off
            placing = false;

            //clear list with temporary waypoint references,
            //we only needed this list for getting first and last waypoint easily
            wpList.Clear();
            //reset path name input field
            pathName = "";
        }

        EditorGUILayout.Space();

        GUILayout.Label("Hint:\nPress 'Start Path' to begin a new path," +
                        "\nALT + Left Click lets you place waypoints\nonto objects." +
                        "\nPress 'Finish Editing' to end your path.");
    }
Exemple #27
0
 private void Awake()
 {
     Instance = this;
     Initialize();
 }
    protected new void Awake()
    {
        base.Awake();
        transform.position = Vector3.zero;

        if (waypoints == null)  {
            name = "WaypointPlayer";
            var go = new GameObject();
            go.transform.parent = transform;
            go.AddComponent("WaypointManager");
            waypoints = go.GetComponent<WaypointManager>();
            waypoints.SetListener(this);
        } else {
            waypoints.SetListener(this);
        }

        name = "WaypointGuard " + guardID;
    }
        private void setup()
        {
            generator = new System.Random(this.Root.MissionSeed);

            iconWaypoints = new List <Waypoint>();

            for (int cardinals = 0; cardinals < 4; cardinals++)
            {
                bool addedWaypoint = false;

                switch (cardinals)
                {
                case 0:
                    if (HighLogic.LoadedSceneIsFlight)
                    {
                        iconWaypoints.Add(new Waypoint());
                        iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.ASCENDINGNODE;
                        addedWaypoint = true;
                    }
                    break;

                case 1:
                    if (HighLogic.LoadedSceneIsFlight)
                    {
                        iconWaypoints.Add(new Waypoint());
                        iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.DESCENDINGNODE;
                        addedWaypoint = true;
                    }
                    break;

                case 2:
                    iconWaypoints.Add(new Waypoint());
                    iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.APOAPSIS;
                    addedWaypoint = true;
                    break;

                case 3:
                    iconWaypoints.Add(new Waypoint());
                    iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.PERIAPSIS;
                    addedWaypoint = true;
                    break;
                }

                if (addedWaypoint)
                {
                    iconWaypoints[iconWaypoints.Count - 1].celestialName = targetBody.GetName();
                    iconWaypoints[iconWaypoints.Count - 1].isOnSurface   = false;
                    iconWaypoints[iconWaypoints.Count - 1].isNavigatable = false;
                    iconWaypoints[iconWaypoints.Count - 1].seed          = Root.MissionSeed;
                    WaypointManager.AddWaypoint(iconWaypoints[iconWaypoints.Count - 1]);
                }
            }

            for (int x = 0; x < numSpinners; x++)
            {
                iconWaypoints.Add(new Waypoint());
                iconWaypoints[iconWaypoints.Count - 1].celestialName = targetBody.GetName();
                iconWaypoints[iconWaypoints.Count - 1].waypointType  = WaypointType.ORBITAL;
                iconWaypoints[iconWaypoints.Count - 1].isOnSurface   = false;
                iconWaypoints[iconWaypoints.Count - 1].isNavigatable = false;
                iconWaypoints[iconWaypoints.Count - 1].seed          = Root.MissionSeed;
                WaypointManager.AddWaypoint(iconWaypoints[iconWaypoints.Count - 1]);
            }

            orbitDriver       = new OrbitDriver();
            orbitDriver.orbit = new Orbit();
            orbitDriver.orbit.referenceBody       = targetBody;
            orbitDriver.orbit.semiMajorAxis       = sma;
            orbitDriver.orbit.eccentricity        = eccentricity;
            orbitDriver.orbit.argumentOfPeriapsis = argumentOfPeriapsis;
            orbitDriver.orbit.inclination         = inclination;
            orbitDriver.orbit.LAN = lan;
            orbitDriver.orbit.meanAnomalyAtEpoch = meanAnomalyAtEpoch;
            orbitDriver.orbit.epoch = epoch;
            orbitDriver.orbit.Init();
            //The orbit needs to be post processed in an appropriate scene, or it will be useless.
            Util.PostProcessOrbit(ref orbitDriver.orbit);

            orbitDriver.orbitColor = WaypointManager.RandomColor(Root.MissionSeed);

            orbitRenderer            = MapView.MapCamera.gameObject.AddComponent <OrbitRenderer>();
            orbitRenderer.driver     = orbitDriver;
            orbitRenderer.drawIcons  = OrbitRenderer.DrawIcons.NONE;
            orbitRenderer.drawNodes  = false;
            orbitRenderer.orbitColor = WaypointManager.RandomColor(Root.MissionSeed);

            setVisible(true);

            orbitRenderer.celestialBody = targetBody;

            beenSetup = true;
        }
Exemple #30
0
 private void Awake()
 {
     waypointManager = FindObjectOfType <WaypointManager>();
     creepManager    = FindObjectOfType <CreepManager>();
 }
Exemple #31
0
 public void assignPath(WaypointManager wpm)
 {
     brickPath = wpm;
 }
 private void Awake()
 {
     waypointManager = GetComponent<WaypointManager>();
     targetGO = waypointManager.NextWaypoint(null);
 }
Exemple #33
0
    public void setupPath()
    {
        if (isRandomSpawn == false && initWp != null)
        {
            currentWP = initWp;
        }
        else
        {
            currentWP = brickPath.pickRandomWP();
            initWp = currentWP;
        }

        if (type == typeList.Chainsaw && isRandomSpawn == true)
        {
            gameObject.transform.position = currentWP.transform.position;
        }

        if (type == typeList.Bird)
        {
            GameObject spw = GameObject.Find("LevelManager/Enviro/OuterSpawn");
            gameObject.transform.position = new Vector3(spw.transform.position.x, spw.transform.position.y, 0f);
        }

        initPath = brickPath;
        setupTarget();
    }
Exemple #34
0
 public void Setup()
 {
     transform.position = new Vector3(transform.position.x, transform.position.y, 0f);
     linkedManager = transform.parent.GetComponent<WaypointManager>();
     id = int.Parse(name);
 }
 public override void Start()
 {
     base.Start();
     waypointManager = GameObject.FindGameObjectWithTag ("GameController").GetComponent<WaypointManager>();
 }
Exemple #36
0
        /// <summary>
        /// Function to initialize the Enemy from code.
        /// </summary>
        /// <param name="position">The position on the map to spawn the enemy.</param>
        /// <param name="waypointMap">The object that manages the list of Waypoints and updates them.</param>
        /// <param name="listOfPlayers">A list of all Players in the scene.</param>
        /// <param name="enemyManager">The parent that manages this Enemy.</param>
        public void Init(Vector3 position, WaypointManager waypointMap, List<GameObject> listOfPlayers, EnemyManager enemyManager)
        {
            // Set the WaypointMap
            WaypointMap = waypointMap;

            // Set the list of players
            PlayerList = listOfPlayers;

            // Set the Enemy Manager (parent manager)
            Manager = enemyManager;

            // Reset Values
            Reset(position);
        }
 void Awake()
 {
     WaypointManager.AddPath(gameObject);
 }
Exemple #38
0
    /// <summary>
    /// Sets the target..
    /// </summary>
    void Update()
    {
        if (_characterStatus.IsInvulnerable)
        {
            return;
        }

        #region Found Player

        if (_targetSelector.CurrentTarget != null)
        {
            Vector3 targetPos  = _targetSelector.CurrentTarget.transform.position;
            Vector3 entityPos  = transform.position;
            Vector3 difference = (targetPos - entityPos);
            float   distance   = difference.sqrMagnitude;


            if (distance > ShootingDistance)
            {
                _agent.destination = _targetSelector.CurrentTarget.transform.position;
                _running           = false;
            }
            else if (distance < PanicDistance || _running)
            {
                _agent.destination = entityPos - difference;
                _running           = true;
            }
            else if (!_running)
            {
                // Lookat and shoot.
                _agent.destination = entityPos;
                transform.LookAt(targetPos);

                if (!_cooldown)
                {
                    Fire();
                    StartCoroutine(Cooldown());
                }
            }
        }
        else
        {
            #region Follow Path

            if (_currentCheckpoint == null)
            {
                _currentCheckpoint = WaypointManager.GetCheckpoint(_currentOrder);
            }

            if (_currentCheckpoint != null)
            {
                _agent.destination = _currentCheckpoint.Position;

                if ((_currentCheckpoint.Position - transform.position).magnitude < 0.1)
                {
                    _currentOrder++;
                    _currentCheckpoint = null;
                }
            }
            else
            {
                // If Checkpoint was null, it doesn't exist.
                _currentOrder = 0;
            }

            #endregion Follow Path
        }

        #endregion Found Player



        #region Animation
        if (Animator != null)
        {
            Animator.SetFloat("Speed", _agent.speed);
        }
        #endregion Animation
    }
 private void Awake()
 {
     Get = this;
 }
Exemple #40
0
    // Use this for initialization
    void Start()
    {
        wpm = GameObject.FindObjectOfType <WaypointManager>();

        exitTransform = GetExit(wpm.waypointNodes);
    }
Exemple #41
0
 private void Start()
 {
     uim = GameObject.FindObjectOfType <UIManager>();
     wpm = GameObject.FindObjectOfType <WaypointManager>();
     //gameState = GameState.Playing;
 }
Exemple #42
0
        protected override void OnUpdate()
        {
            if (this.Root.ContractState == Contract.State.Active)
            {
                if (HighLogic.LoadedSceneIsFlight)
                {
                    if (FlightGlobals.ready)
                    {
                        Vessel v            = FlightGlobals.ActiveVessel;
                        float  distanceToWP = float.PositiveInfinity;

                        if (submittedWaypoint && v.mainBody == targetBody)
                        {
                            if (WaypointManager.Instance() != null)
                            {
                                distanceToWP = WaypointManager.Instance().LateralDistanceToVessel(wp);

                                if (distanceToWP > FPConfig.Rover.TriggerRange * 2 && outerWarning)
                                {
                                    outerWarning = false;
                                    ScreenMessages.PostScreenMessage("You are leaving the target area of " + wp.tooltip + ".", 5.0f, ScreenMessageStyle.UPPER_LEFT);
                                }

                                if (distanceToWP <= FPConfig.Rover.TriggerRange * 2 && !outerWarning)
                                {
                                    outerWarning = true;
                                    ScreenMessages.PostScreenMessage("Approaching target area of " + wp.tooltip + ", checking for anomalous data.", 5.0f, ScreenMessageStyle.UPPER_LEFT);
                                }

                                if (distanceToWP < FPConfig.Rover.TriggerRange)
                                {
                                    if (Util.hasWheelsOnGround())
                                    {
                                        if (isSecret)
                                        {
                                            ScreenMessages.PostScreenMessage("This is the source of the anomalous data that we've been looking for in " + wp.tooltip + "!", 5.0f, ScreenMessageStyle.UPPER_LEFT);

                                            foreach (RoverWaypointParameter parameter in Root.AllParameters)
                                            {
                                                if (parameter != null && parameter != this)
                                                {
                                                    if (parameter.State != ParameterState.Complete)
                                                    {
                                                        parameter.wp.isExplored = true;
                                                        WaypointManager.deactivateNavPoint(wp);
                                                        WaypointManager.RemoveWaypoint(parameter.wp);
                                                        parameter.submittedWaypoint = false;
                                                        parameter.SetComplete();
                                                    }
                                                }
                                            }

                                            base.SetComplete();
                                            Root.Complete();
                                        }
                                        else
                                        {
                                            ScreenMessages.PostScreenMessage(Util.generateRoverFailString(Root.MissionSeed, waypointID), 5.0f, ScreenMessageStyle.UPPER_LEFT);
                                            wp.isExplored = true;
                                            WaypointManager.deactivateNavPoint(wp);
                                            WaypointManager.RemoveWaypoint(wp);
                                            submittedWaypoint = false;
                                            base.SetComplete();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 // Use this for initialization
 void Awake()
 {
     managerRoad = this;
 }
Exemple #44
0
        public void MakeDefault()
        {
            m_Props.Clear();

            AddProperty("ShowMobNames", false);
            AddProperty("ShowCorpseNames", false);
            AddProperty("DisplaySkillChanges", false);

            if (Client.IsOSI)
            {
                AddProperty("TitleBarText", @"UO - {char} {crimtime}- {mediumstatbar} {bp} {bm} {gl} {gs} {mr} {ns} {ss} {sa} {aids}");
            }
            else
            {
                AddProperty("TitleBarText", @"UO - {char}");
            }

            AddProperty("TitleBarDisplay", true);
            AddProperty("AutoSearch", true);
            AddProperty("NoSearchPouches", true);
            AddProperty("CounterWarnAmount", (int)5);
            AddProperty("CounterWarn", true);
            AddProperty("ObjectDelay", (int)600);
            AddProperty("ObjectDelayEnabled", true);
            AddProperty("AlwaysOnTop", false);
            AddProperty("SortCounters", true);
            AddProperty("QueueActions", false);
            AddProperty("QueueTargets", false);
            AddProperty("WindowX", (int)400);
            AddProperty("WindowY", (int)400);
            AddProperty("CountStealthSteps", true);

            AddProperty("SysColor", (int)0x0044);
            AddProperty("WarningColor", (int)0x0025);
            AddProperty("ExemptColor", (int)0x0480);
            AddProperty("SpeechHue", (int)0x03B1);
            AddProperty("BeneficialSpellHue", (int)0x0005);
            AddProperty("HarmfulSpellHue", (int)0x0058);
            AddProperty("NeutralSpellHue", (int)0x03B1);
            AddProperty("ForceSpeechHue", false);
            AddProperty("ForceSpellHue", true);
            AddProperty("SpellFormat", @"{power} [{spell}]");

            AddProperty("ShowNotoHue", true);
            AddProperty("Opacity", (int)100);

            AddProperty("AutoOpenCorpses", false);
            AddProperty("CorpseRange", (int)2);

            AddProperty("BlockDismount", false);

            AddProperty("CapFullScreen", false);
            AddProperty("CapPath",
                        Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RazorScreenShots"));
            AddProperty("CapTimeStamp", true);
            AddProperty("ImageFormat", "jpg");

            AddProperty("UndressConflicts", true);
            AddProperty("HighlightReagents", true);
            AddProperty("Systray", false);
            AddProperty("TitlebarImages", true);

            AddProperty("SellAgentMax", (int)99);
            AddProperty("SkillListCol", (int)-1);
            AddProperty("SkillListAsc", false);

            AddProperty("AutoStack", false);
            AddProperty("ActionStatusMsg", true);
            AddProperty("RememberPwds", false);

            AddProperty("SpellUnequip", true);
            AddProperty("RangeCheckLT", true);
            AddProperty("LTRange", (int)12);

            AddProperty("FilterSnoopMsg", true);
            AddProperty("OldStatBar", false);

            AddProperty("SmartLastTarget", false);
            AddProperty("LastTargTextFlags", true);
            //AddProperty("SmartCPU", false);
            AddProperty("LTHilight", (int)0);

            AddProperty("AutoFriend", false);

            AddProperty("AutoOpenDoors", true);

            AddProperty("MessageLevel", 0);

            AddProperty("ForceIP", "");
            AddProperty("ForcePort", 0);

            AddProperty("ForceSizeEnabled", false);
            AddProperty("ForceSizeX", 1000);
            AddProperty("ForceSizeY", 800);

            AddProperty("PotionEquip", false);
            AddProperty("BlockHealPoison", true);

            AddProperty("SmoothWalk", false);

            AddProperty("Negotiate", true);

            AddProperty("MapX", 200);
            AddProperty("MapY", 200);
            AddProperty("MapW", 200);
            AddProperty("MapH", 200);

            AddProperty("LogPacketsByDefault", false);

            AddProperty("ShowHealth", true);
            AddProperty("HealthFmt", "[{0}%]");
            AddProperty("ShowPartyStats", true);
            AddProperty("PartyStatFmt", "[{0}% / {1}%]");

            AddProperty("HotKeyStop", false);
            AddProperty("DiffTargetByType", false);
            AddProperty("StepThroughMacro", false);

            AddProperty("ShowTargetSelfLastClearOverhead", true);
            AddProperty("ShowOverheadMessages", false);
            AddProperty("CaptureMibs", false);

            //OverheadFormat
            AddProperty("OverheadFormat", "[{msg}]");
            AddProperty("OverheadStyle", 1);

            AddProperty("GoldPerDisplay", false);

            AddProperty("LightLevel", 31);
            AddProperty("LogSkillChanges", false);
            AddProperty("StealthOverhead", false);

            AddProperty("ShowBuffDebuffOverhead", true);
            AddProperty("BuffDebuffFormat", "[{action}{name} {duration}]");

            AddProperty("BlockOpenCorpsesTwice", false);

            AddProperty("ShowAttackTargetOverhead", true);

            AddProperty("RangeCheckTargetByType", false);
            AddProperty("RangeCheckDoubleClick", false);

            AddProperty("ShowContainerLabels", false);
            AddProperty("ContainerLabelFormat", "[{label}] ({type})");
            AddProperty("ContainerLabelColor", 88);
            AddProperty("ContainerLabelStyle", 1);

            AddProperty("Season", 5);

            AddProperty("BlockTradeRequests", false);
            AddProperty("BlockPartyInvites", false);
            AddProperty("AutoAcceptParty", false);

            AddProperty("MaxLightLevel", 31);
            AddProperty("MinLightLevel", 0);
            AddProperty("MinMaxLightLevelEnabled", false);
            AddProperty("ShowStaticWalls", false);
            AddProperty("ShowStaticWallLabels", false);

            AddProperty("ShowTextTargetIndicator", false);
            AddProperty("ShowAttackTargetNewOnly", true);

            AddProperty("FilterDragonGraphics", false);
            AddProperty("FilterDrakeGraphics", false);
            AddProperty("DragonGraphic", 0);
            AddProperty("DrakeGraphic", 0);

            AddProperty("ShowDamageDealt", false);
            AddProperty("ShowDamageDealtOverhead", false);
            AddProperty("ShowDamageTaken", false);
            AddProperty("ShowDamageTakenOverhead", false);

            AddProperty("ShowInRazorTitleBar", false);
            AddProperty("RazorTitleBarText", "{name} on {account} ({profile} - {shard}) - Razor v{version}");

            AddProperty("EnableUOAAPI", true);

            AddProperty("TargetIndicatorFormat", "* Target *");

            AddProperty("NextPrevTargetIgnoresFriends", false);

            AddProperty("StealthStepsFormat", "Steps: {step}");

            AddProperty("ShowFriendOverhead", false);

            AddProperty("DisplaySkillChangesOverhead", false);

            AddProperty("GrabHotBag", "0");

            // Enable it for OSI client by default, CUO turn it off
            AddProperty("MacroActionDelay", Client.IsOSI);

            AddProperty("AutoOpenDoorWhenHidden", false);

            AddProperty("DisableMacroPlayFinish", false);

            AddProperty("ShowBandageTimer", false);
            AddProperty("ShowBandageTimerFormat", "Bandage: {count}s");
            AddProperty("ShowBandageTimerLocation", 0);
            AddProperty("OnlyShowBandageTimerEvery", false);
            AddProperty("OnlyShowBandageTimerSeconds", 1);
            AddProperty("ShowBandageTimerHue", 88);

            AddProperty("TargetIndicatorHue", 10);

            AddProperty("FilterSystemMessages", false);
            AddProperty("FilterRazorMessages", false);
            AddProperty("FilterDelay", 3.5);
            AddProperty("FilterOverheadMessages", false);

            AddProperty("OnlyNextPrevBeneficial", false);
            AddProperty("FriendlyBeneficialOnly", false);
            AddProperty("NonFriendlyHarmfulOnly", false);

            AddProperty("ShowBandageStart", false);
            AddProperty("BandageStartMessage", "Bandage: Starting");
            AddProperty("ShowBandageEnd", false);
            AddProperty("BandageEndMessage", "Bandage: Ending");

            AddProperty("BuffDebuffSeconds", 20);
            AddProperty("BuffHue", 88);
            AddProperty("DebuffHue", 338);
            AddProperty("DisplayBuffDebuffEvery", false);
            AddProperty("BuffDebuffFilter", string.Empty);
            AddProperty("BuffDebuffEveryXSeconds", false);

            AddProperty("CaptureOthersDeathDelay", 0.5);
            AddProperty("CaptureOwnDeathDelay", 0.5);
            AddProperty("CaptureOthersDeath", false);
            AddProperty("CaptureOwnDeath", false);

            AddProperty("TargetFilterEnabled", false);

            AddProperty("FilterDaemonGraphics", false);
            AddProperty("DaemonGraphic", 0);

            AddProperty("SoundFilterEnabled", false);
            AddProperty("ShowFilteredSound", false);
            AddProperty("ShowPlayingSoundInfo", false);
            AddProperty("ShowMusicInfo", false);

            AddProperty("AutoSaveScript", false);
            AddProperty("AutoSaveScriptPlay", false);

            AddProperty("HighlightFriend", false);

            AddProperty("ScriptDisablePlayFinish", false);

            AddProperty("ShowWaypointOverhead", true);
            AddProperty("ShowWaypointDistance", true);
            AddProperty("ShowWaypointSeconds", 10);

            AddProperty("ClearWaypoint", false);
            AddProperty("HideWaypointDistance", 4);

            AddProperty("CreateWaypointOnDeath", false);

            AddProperty("ShowPartyFriendOverhead", false);

            AddProperty("OverrideSpellFormat", true);

            AddProperty("PotionReequip", true);

            AddProperty("EnableTextFilter", false);

            AddProperty("DisableScriptTooltips", false);

            AddProperty("BuyAgentsIgnoreGold", false);

            AddProperty("OverrideBuffDebuffFormat", false);

            Counter.Default();
            Filter.DisableAll();
            DressList.ClearAll();
            HotKey.ClearAll();
            Agent.ClearAll();
            PasswordMemory.ClearAll();
            FriendsManager.ClearAll();
            WaypointManager.ClearAll();
            TextFilterManager.ClearAll();
            DressList.ClearAll();
            OverheadManager.ClearAll();
            ContainerLabels.ClearAll();
            MacroVariables.ClearAll();
            ScriptVariables.ClearAll();
        }
Exemple #45
0
        private void customStartup(parameterContainer p)
        {
            Type       t = p.CParam.GetType();
            GameScenes s = HighLogic.LoadedScene;

            try
            {
                if (t == typeof(ReachDestination) && s == GameScenes.FLIGHT && FlightGlobals.ActiveVessel != null)
                {
                    if (p.CParam.State == ParameterState.Incomplete && ((ReachDestination)p.CParam).checkVesselDestination(FlightGlobals.ActiveVessel))
                    {
                        MethodInfo m = (typeof(ContractParameter)).GetMethod("SetComplete", BindingFlags.NonPublic | BindingFlags.Instance);

                        if (m == null)
                        {
                            return;
                        }

                        m.Invoke(p.CParam, null);
                    }
                    else if (p.CParam.State == ParameterState.Complete && !((ReachDestination)p.CParam).checkVesselDestination(FlightGlobals.ActiveVessel))
                    {
                        MethodInfo m = (typeof(ContractParameter)).GetMethod("SetIncomplete", BindingFlags.NonPublic | BindingFlags.Instance);

                        if (m == null)
                        {
                            return;
                        }

                        m.Invoke(p.CParam, null);
                    }
                }
                else if (t == typeof(ReachSituation) && s == GameScenes.FLIGHT && FlightGlobals.ActiveVessel != null)
                {
                    if (p.CParam.State == ParameterState.Incomplete && ((ReachSituation)p.CParam).checkVesselSituation(FlightGlobals.ActiveVessel))
                    {
                        MethodInfo m = (typeof(ContractParameter)).GetMethod("SetComplete", BindingFlags.NonPublic | BindingFlags.Instance);

                        if (m == null)
                        {
                            return;
                        }

                        m.Invoke(p.CParam, null);
                    }
                    else if (p.CParam.State == ParameterState.Complete && !((ReachSituation)p.CParam).checkVesselSituation(FlightGlobals.ActiveVessel))
                    {
                        MethodInfo m = (typeof(ContractParameter)).GetMethod("SetIncomplete", BindingFlags.NonPublic | BindingFlags.Instance);

                        if (m == null)
                        {
                            return;
                        }

                        m.Invoke(p.CParam, null);
                    }
                }
                else if (t == typeof(SpecificOrbitParameter) && s == GameScenes.FLIGHT)
                {
                    ((SpecificOrbitParameter)p.CParam).SetupRenderer();
                }
                else if (t == typeof(VesselSystemsParameter) && s == GameScenes.FLIGHT)
                {
                    VesselSystemsParameter sys = (VesselSystemsParameter)p.CParam;

                    MethodInfo m = (typeof(VesselSystemsParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke(sys, null);

                    if (!sys.requireNew)
                    {
                        return;
                    }

                    Vessel v = FlightGlobals.ActiveVessel;

                    if (v == null)
                    {
                        return;
                    }

                    if (v.situation != Vessel.Situations.PRELAUNCH)
                    {
                        return;
                    }

                    uint launchID = v.Parts.Min(r => r.launchID);

                    sys.launchID = launchID;
                }
                else if (t == typeof(SurveyWaypointParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(SurveyWaypointParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((SurveyWaypointParameter)p.CParam, null);

                    if (p.Way == null)
                    {
                        return;
                    }

                    var waypoints = WaypointManager.Instance().Waypoints;

                    if (waypoints.Contains(p.Way))
                    {
                        return;
                    }

                    WaypointManager.AddWaypoint(p.Way);
                }
                else if (t == typeof(StationaryPointParameter) && s == GameScenes.FLIGHT)
                {
                    if (p.Way == null)
                    {
                        return;
                    }

                    var waypoints = WaypointManager.Instance().Waypoints;

                    if (waypoints.Contains(p.Way))
                    {
                        return;
                    }

                    WaypointManager.AddWaypoint(p.Way);
                }
                else if (t == typeof(AsteroidParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(AsteroidParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((AsteroidParameter)p.CParam, null);
                }
                else if (t == typeof(CrewCapacityParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(CrewCapacityParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((CrewCapacityParameter)p.CParam, null);
                }
                else if (t == typeof(CrewTraitParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(CrewTraitParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((CrewTraitParameter)p.CParam, null);
                }
                else if (t == typeof(KerbalDestinationParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(KerbalDestinationParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((KerbalDestinationParameter)p.CParam, null);
                }
                else if (t == typeof(KerbalTourParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(KerbalTourParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((KerbalTourParameter)p.CParam, null);
                }
                else if (t == typeof(KerbalGeeAdventureParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(KerbalGeeAdventureParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((KerbalGeeAdventureParameter)p.CParam, null);
                }
                else if (t == typeof(LocationAndSituationParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(LocationAndSituationParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((LocationAndSituationParameter)p.CParam, null);
                }
                else if (t == typeof(MobileBaseParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(MobileBaseParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((MobileBaseParameter)p.CParam, null);
                }
                else if (t == typeof(PartRequestParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(PartRequestParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((PartRequestParameter)p.CParam, null);
                }
                else if (t == typeof(ProgressTrackingParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(ProgressTrackingParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((ProgressTrackingParameter)p.CParam, null);
                }
                else if (t == typeof(ResourceExtractionParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(ResourceExtractionParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((ResourceExtractionParameter)p.CParam, null);
                }
                else if (t == typeof(VesselDestinationParameter) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(VesselDestinationParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((VesselDestinationParameter)p.CParam, null);
                }
                else if (t == typeof(RecoverKerbal) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(RecoverKerbal)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((RecoverKerbal)p.CParam, null);
                }
                else if (t == typeof(RecoverPart) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(RecoverPart)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((RecoverPart)p.CParam, null);
                }
                else if (t == typeof(AcquirePart) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(AcquirePart)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((AcquirePart)p.CParam, null);
                }
                else if (t == typeof(AcquireCrew) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(AcquireCrew)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((AcquireCrew)p.CParam, null);
                }
                else if (t == typeof(PartTest) && s == GameScenes.FLIGHT)
                {
                    MethodInfo m = (typeof(PartTest)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance);

                    if (m == null)
                    {
                        return;
                    }

                    m.Invoke((PartTest)p.CParam, null);

                    if (((PartTest)p.CParam).hauled)
                    {
                        return;
                    }

                    AvailablePart targetPart = ((PartTest)p.CParam).tgtPartInfo;

                    if (targetPart == null)
                    {
                        return;
                    }

                    for (int i = FlightGlobals.VesselsLoaded.Count - 1; i >= 0; i--)
                    {
                        Vessel v = FlightGlobals.VesselsLoaded[i];

                        if (v == null)
                        {
                            continue;
                        }

                        for (int j = v.Parts.Count - 1; j >= 0; j--)
                        {
                            Part part = v.Parts[j];

                            if (part == null)
                            {
                                continue;
                            }

                            if (part.partInfo != targetPart)
                            {
                                continue;
                            }

                            var mods = part.FindModulesImplementing <ModuleTestSubject>();

                            for (int k = 0; k < mods.Count; k++)
                            {
                                ModuleTestSubject test = mods[k];

                                if (test == null)
                                {
                                    continue;
                                }

                                test.Events["RunTestEvent"].active = true;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LogFormatted("Error while forcing Contract Parameter activation:\n{0}", e);
            }
        }
Exemple #46
0
    // Use this for initialization
    protected override void Start()
    {
        TotalSize = ScreenData.GetScreenSize();
        tileSize = calculateTileSize(TotalSize);
        base.Start();

        // Initialize Components
        waypointManager = GetComponent<WaypointManager>();
    }
Exemple #47
0
        public void Initialize()
        {
            if (!initialized)
            {
                LoggingUtil.LogVerbose(this, "Initializing waypoint generator.");
                foreach (WaypointData wpData in waypoints)
                {
                    CelestialBody body = FlightGlobals.Bodies.Where <CelestialBody>(b => b.name == wpData.waypoint.celestialName).FirstOrDefault();
                    if (body == null)
                    {
                        continue;
                    }

                    // Do type-specific waypoint handling
                    if (wpData.type == "RANDOM_WAYPOINT")
                    {
                        LoggingUtil.LogVerbose(this, "   Generating a random waypoint...");

                        while (true)
                        {
                            // Generate the position
                            WaypointManager.ChooseRandomPosition(out wpData.waypoint.latitude, out wpData.waypoint.longitude,
                                                                 wpData.waypoint.celestialName, wpData.waterAllowed, wpData.forceEquatorial, random);

                            // Force a water waypoint
                            if (wpData.underwater)
                            {
                                Vector3d radialVector = QuaternionD.AngleAxis(wpData.waypoint.longitude, Vector3d.down) *
                                                        QuaternionD.AngleAxis(wpData.waypoint.latitude, Vector3d.forward) * Vector3d.right;
                                if (body.pqsController.GetSurfaceHeight(radialVector) - body.pqsController.radius >= 0.0)
                                {
                                    continue;
                                }
                            }
                            break;
                        }
                    }
                    else if (wpData.type == "RANDOM_WAYPOINT_NEAR")
                    {
                        Waypoint nearWaypoint = waypoints[wpData.nearIndex].waypoint;

                        LoggingUtil.LogVerbose(this, "   Generating a random waypoint near waypoint {0}...", nearWaypoint.name);

                        if (!nearWaypoint.celestialBody.hasSolidSurface)
                        {
                            wpData.waterAllowed = true;
                        }


                        // Convert input to radians
                        double rlat1 = nearWaypoint.latitude * Math.PI / 180.0;
                        double rlon1 = nearWaypoint.longitude * Math.PI / 180.0;

                        for (int i = 0; i < 10000; i++)
                        {
                            // Sliding window
                            double window = (i < 100 ? 1 : (1.01 * (i - 100 + 1)));
                            double max    = wpData.maxDistance * window;
                            double min    = wpData.minDistance / window;

                            // Distance between our point and the random waypoint
                            double d = min + random.NextDouble() * (max - min);

                            // Random bearing
                            double brg = random.NextDouble() * 2.0 * Math.PI;

                            // Angle between our point and the random waypoint
                            double a = d / nearWaypoint.celestialBody.Radius;

                            // Calculate the coordinates
                            double rlat2 = Math.Asin(Math.Sin(rlat1) * Math.Cos(a) + Math.Cos(rlat1) * Math.Sin(a) * Math.Cos(brg));
                            double rlon2;

                            // Check for pole
                            if (Math.Abs(Math.Cos(rlat1)) < 0.0001)
                            {
                                rlon2 = rlon1;
                            }
                            else
                            {
                                rlon2 = ((rlon1 - Math.Asin(Math.Sin(brg) * Math.Sin(a) / Math.Cos(rlat2)) + Math.PI) % (2.0 * Math.PI)) - Math.PI;
                            }

                            wpData.waypoint.latitude  = rlat2 * 180.0 / Math.PI;
                            wpData.waypoint.longitude = rlon2 * 180.0 / Math.PI;

                            // Calculate the waypoint altitude
                            Vector3d radialVector = QuaternionD.AngleAxis(wpData.waypoint.longitude, Vector3d.down) *
                                                    QuaternionD.AngleAxis(wpData.waypoint.latitude, Vector3d.forward) * Vector3d.right;
                            double altitude = body.pqsController.GetSurfaceHeight(radialVector) - body.pqsController.radius;

                            // Check water conditions if required
                            if (!nearWaypoint.celestialBody.hasSolidSurface || !nearWaypoint.celestialBody.ocean || (wpData.waterAllowed && !wpData.underwater) || (wpData.underwater && altitude < 0) || (!wpData.underwater && altitude > 0))
                            {
                                break;
                            }
                        }
                    }
                    else if (wpData.type == "PQS_CITY")
                    {
                        GeneratePQSCityCoordinates(wpData, body);
                    }
                    else if (wpData.type == "LAUNCH_SITE")
                    {
                        GenerateLaunchSiteCoordinates(wpData, body);
                    }

                    // Set altitude
                    SetAltitude(wpData, body);

                    LoggingUtil.LogVerbose(this, "   Generated waypoint {0} at {1}, {2}.", wpData.waypoint.name, wpData.waypoint.latitude, wpData.waypoint.longitude);
                }

                initialized = true;
                LoggingUtil.LogVerbose(this, "Waypoint generator initialized.");
            }
        }
 void Awake()
 {
     _instance = this;
 }
        public override void OnInspectorGUI()
        {
            var grid = target as Grid;

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Grid Row");
            grid.m_keepRow = EditorGUILayout.IntField(grid.m_keepRow);            //("Grid Row", grid.m_keepRow, 1, 1024);
            GUILayout.EndHorizontal();
            for (int i = 0; i < 100; ++i)
            {
                if (Grid.GridSizeDelta * i >= grid.m_keepRow)
                {
                    grid.m_keepRow = Grid.GridSizeDelta * i;
                    break;
                }
            }
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Grid Column");
            grid.m_keepColumn = EditorGUILayout.IntField(grid.m_keepColumn);            //("Grid Column", grid.m_keepColumn, 1, 1024);
            GUILayout.EndHorizontal();
            for (int j = 0; j < 100; ++j)
            {
                if (Grid.GridSizeDelta * j >= grid.m_keepColumn)
                {
                    grid.m_keepColumn = Grid.GridSizeDelta * j;
                    break;
                }
            }
            grid.GridSize = EditorGUILayout.Slider("Grid Size", grid.GridSize, 0.1f, 3.0f);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Resize"))
            {
                if (grid.m_keepRow != grid.Row || grid.m_keepColumn != grid.Column)
                {
                    grid.Resize(grid.m_keepRow, grid.m_keepColumn);
                    SceneView.RepaintAll();
                }
            }
            if (GUILayout.Button("Fit to ground"))
            {
                grid.FitToGround();
                SceneView.RepaintAll();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Export"))
            {
                string filepath = EditorUtility.SaveFilePanelInProject("Save Map", "GridInfo", "txt", "OKOK");
                LogManager.Log(filepath);
//				string fileName = filepath;//文件名字

                StringBuilder sb = new StringBuilder();
                //offset
                sb.Append("type octile").Append("\r\n");
                Vector3 offset = grid.transform.position;
                FP      x      = (FP)offset.x;
                sb.Append("X ").Append(x.RawValue).Append("\r\n");
                FP z = (FP)offset.z;
                sb.Append("Z ").Append(z.RawValue).Append("\r\n");
                sb.Append("width ").Append(grid.Column).Append("\r\n");
                sb.Append("height ").Append(grid.Row).Append("\r\n");
                FP size = (FP)grid.GridSize;
                sb.Append("size ").Append(size.RawValue).Append("\r\n");
                sb.Append("map").Append("\r\n");

                for (int i = 0; i < grid.Row; ++i)
                {
                    for (int j = 0; j < grid.Column; ++j)
                    {
                        Cell c = grid.GetCell(i, j);
                        if (c.collision == Cell.CollisionType.Unwalkable)
                        {
                            sb.Append('@');
                        }
                        else
                        {
                            int ascCode = (int)c.material + '0';
                            sb.Append((char)ascCode);
                        }
                    }
                    sb.Append("\r\n");
                }
                //要写的数据源
                EditorUtils.SaveTextFile(filepath, sb.ToString());
            }
            if (GUILayout.Button("Import"))
            {
                string filepath = EditorUtility.OpenFilePanel("Load map", Application.dataPath, "txt");
                if (filepath != null)
                {
                    StreamReader reader = new StreamReader(filepath, new UTF8Encoding(false));
                    if (reader != null)
                    {
                        SWS.MapGridT  myGrid  = new SWS.MapGridT();
                        string        content = reader.ReadToEnd();
                        int           readPos = 0;
                        List <string> kv      = null;
                        while (readPos < content.Length)
                        {
                            string line = EditorUtils.readLine(content, ref readPos);
                            kv = EditorUtils.splitLine(line);
                            if (kv.Count == 0)
                            {
                                continue;
                            }
                            if (kv[0] == "map")
                            {
                                break;
                            }
                            if (kv[0] == "X")
                            {
                                if (kv.Count > 1)
                                {
                                    myGrid.X = FP.FromRaw(long.Parse(kv[1]));
                                }
                            }
                            if (kv[0] == "Z")
                            {
                                if (kv.Count > 1)
                                {
                                    myGrid.Z = FP.FromRaw(long.Parse(kv[1]));
                                }
                            }
                            if (kv[0] == "width")
                            {
                                if (kv.Count > 1)
                                {
                                    myGrid.Width = int.Parse(kv[1]);
                                }
                            }
                            if (kv[0] == "height")
                            {
                                if (kv.Count > 1)
                                {
                                    myGrid.Height = int.Parse(kv[1]);
                                }
                            }
                            if (kv[0] == "size")
                            {
                                if (kv.Count > 1)
                                {
                                    myGrid.GridSize = FP.FromRaw(long.Parse(kv[1]));
                                }
                            }
                        }
                        if (myGrid.Width == 0 || myGrid.Height == 0)
                        {
                            StringBuilder log = new StringBuilder();
                            log.Append("invlid width").Append(myGrid.Width).Append("or height").Append(myGrid.Height);
                            LogManager.Log(log.ToString());
                            return;
                        }
                        grid.transform.position = new Vector3((float)myGrid.X, 0f, (float)myGrid.Z);
                        grid.GridSize           = (float)myGrid.GridSize;
                        grid.Resize(myGrid.Height, myGrid.Width, false);
                        grid.m_keepRow    = myGrid.Height;
                        grid.m_keepColumn = myGrid.Width;
                        for (int i = 0; i < myGrid.Height; i++)
                        {
                            string line = EditorUtils.readLine(content, ref readPos);
                            if (line.Length < myGrid.Width + 1)
                            {
                                StringBuilder log = new StringBuilder();
                                log.Append("line").Append(i).Append("length is less than").Append(myGrid.Width);
                                LogManager.Log(log.ToString());
                                return;
                            }
                            for (int w = 0; w < myGrid.Width; w++)
                            {
                                Cell c = grid.GetCell(i, w);
                                if (line[w] == '@')
                                {
                                    grid.SetCellCollision(i, w, Cell.CollisionType.Unwalkable);
                                }
                                else
                                {
                                    grid.SetCellCollision(i, w, Cell.CollisionType.Walkable);
                                    int enumNum = line[w] - '0';
                                    c.material = (Cell.MaterialType)enumNum;
                                }
                            }
                        }
                        SceneView.RepaintAll();
                    }
                }
            }

            if (GUILayout.Button("MakeAllWalkable"))
            {
                //    Grid grid = target as Grid;
                for (int i = 0; i < grid.Row; ++i)
                {
                    for (int j = 0; j < grid.Column; ++j)
                    {
                        grid.SetCellCollision(i, j, Cell.CollisionType.Walkable);
                    }
                }
            }

            if (GUILayout.Button("CreateFromPath"))
            {
                int       walkNum = 0, nonWalkNum = 0;
                Polygon[] walkables = new Polygon[16];
                for (int a = 0; a < walkables.Length; ++a)
                {
                    walkables[a] = new Polygon();
                }
                Polygon[] nonWalkables = new Polygon[32];
                for (int b = 0; b < nonWalkables.Length; ++b)
                {
                    nonWalkables[b] = new Polygon();
                }
                //get all pathes
                WaypointManager manager = GameObject.FindObjectOfType <WaypointManager>();
                if (manager)
                {
                    Vector3       offset = grid.transform.position;
                    PathManager[] pathes = manager.GetComponentsInChildren <PathManager>();
                    foreach (PathManager path in pathes)
                    {
                        if (path.walkable)
                        {
                            for (int i = 0; i < path.waypoints.Length; ++i)
                            {
                                Vector3 pos = path.waypoints[i].position;
                                walkables[walkNum].m_Points.Add(new Vector2(pos.x - offset.x, pos.z - offset.z));
                            }
                            Vector3 firstPos = path.waypoints[0].position;
                            walkables[walkNum].m_Points.Add(new Vector2(firstPos.x - offset.x, firstPos.z - offset.z));
                            walkNum++;
                        }
                        else
                        {
                            for (int i = 0; i < path.waypoints.Length; ++i)
                            {
                                Vector3 pos = path.waypoints[i].position;
                                nonWalkables[nonWalkNum].m_Points.Add(new Vector2(pos.x - offset.x, pos.z - offset.z));
                            }
                            Vector3 firstPos = path.waypoints[0].position;
                            nonWalkables[nonWalkNum].m_Points.Add(new Vector2(firstPos.x - offset.x, firstPos.z - offset.z));
                            nonWalkNum++;
                        }
                    }
                }
                //int[] gridData = editPlane.GetGridInfo();

                for (int i = 0; i < grid.Row; i++)
                {
                    for (int w = 0; w < grid.Column; w++)
                    {
                        float   gridSize  = grid.GridSize;
                        bool    processed = false;
                        Vector2 pos       = new Vector2(w * gridSize + gridSize * 0.5f, i * gridSize + gridSize * 0.5f);
                        for (int nonWalkIndex = 0; nonWalkIndex < nonWalkNum; ++nonWalkIndex)
                        {
                            if (PtInPolygon(pos, nonWalkables[nonWalkIndex].m_Points))
                            {
                                processed = true;
                                grid.SetCellCollision(i, w, Cell.CollisionType.Unwalkable);
                            }
                        }
                        if (!processed)
                        {
                            for (int walkIndex = 0; walkIndex < walkNum; ++walkIndex)
                            {
                                if (PtInPolygon(pos, walkables[walkIndex].m_Points))
                                {
                                    processed = true;
                                    grid.SetCellCollision(i, w, Cell.CollisionType.Walkable);
                                }
                            }
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            GUILayout.Label("Brush Shap: ");
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Rect1x1), "Rect1x1"))
            {
                grid.m_brushType = Grid.BrushType.Rect1x1;
            }
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Rect3x3), "Rect3x3"))
            {
                grid.m_brushType = Grid.BrushType.Rect3x3;
            }
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Rect5x5), "Rect5x5"))
            {
                grid.m_brushType = Grid.BrushType.Rect5x5;
            }
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Rect7x7), "Rect7x7"))
            {
                grid.m_brushType = Grid.BrushType.Rect7x7;
            }
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Rect9x9), "Rect9x9"))
            {
                grid.m_brushType = Grid.BrushType.Rect9x9;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Cross3x3), "Cross3x3"))
            {
                grid.m_brushType = Grid.BrushType.Cross3x3;
            }
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Cross5x5), "Cross5x5"))
            {
                grid.m_brushType = Grid.BrushType.Cross5x5;
            }
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Cross7x7), "Cross7x7"))
            {
                grid.m_brushType = Grid.BrushType.Cross7x7;
            }
            if (GUILayout.Toggle((grid.m_brushType == Grid.BrushType.Cross9x9), "Cross9x9"))
            {
                grid.m_brushType = Grid.BrushType.Cross9x9;
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            GUILayout.Label("Paint: ");
            GUILayout.BeginVertical();
            var viewType = (Grid.ViewType)EditorGUILayout.EnumPopup(
                "View", grid.m_viewType);

            if (viewType != grid.m_viewType)
            {
                grid.ChangeView(viewType);
            }
            switch (grid.m_viewType)
            {
            case Grid.ViewType.WalkableView:
                grid.m_brushCollision = (Cell.CollisionType)EditorGUILayout.EnumPopup(
                    "Collision", grid.m_brushCollision);
                break;

            case Grid.ViewType.SecurityView:
                grid.m_brushSecurity = (Cell.SecurityType)EditorGUILayout.EnumPopup(
                    "Security", grid.m_brushSecurity);
                break;

            case Grid.ViewType.MaterialView:
                grid.m_brushMaterial = (Cell.MaterialType)EditorGUILayout.EnumPopup(
                    "Material", grid.m_brushMaterial);
                break;
            }
            GUILayout.EndVertical();
        }
 /*----------------------------------------------------------
  * cache references to navmeshagent and waypointmanager sibling components
  * in parent GameObject
  */
 void Start()
 {
     navMeshAgent    = GetComponent <UnityEngine.AI.NavMeshAgent>();
     waypointManager = GetComponent <WaypointManager>();
     HeadForNextWayPoint();
 }
 void Start()
 {
     navMeshAgent = GetComponent<NavMeshAgent>();
     waypointManager = GetComponent<WaypointManager>();
     HeadForNextWayPoint();
 }
        public void Initialize()
        {
            if (!initialized)
            {
                LoggingUtil.LogVerbose(this, "Initializing waypoint generator.");
                foreach (WaypointData wpData in waypoints)
                {
                    CelestialBody body = FlightGlobals.Bodies.Where <CelestialBody>(b => b.name == wpData.waypoint.celestialName).FirstOrDefault();
                    if (body == null)
                    {
                        continue;
                    }

                    // Do type-specific waypoint handling
                    if (wpData.type == "RANDOM_WAYPOINT")
                    {
                        LoggingUtil.LogVerbose(this, "   Generating a random waypoint...");

                        while (true)
                        {
                            // Generate the position
                            WaypointManager.ChooseRandomPosition(out wpData.waypoint.latitude, out wpData.waypoint.longitude,
                                                                 wpData.waypoint.celestialName, wpData.waterAllowed, wpData.forceEquatorial, random);

                            // Force a water waypoint
                            if (wpData.underwater)
                            {
                                Vector3d radialVector = QuaternionD.AngleAxis(wpData.waypoint.longitude, Vector3d.down) *
                                                        QuaternionD.AngleAxis(wpData.waypoint.latitude, Vector3d.forward) * Vector3d.right;
                                if (body.pqsController.GetSurfaceHeight(radialVector) - body.pqsController.radius >= 0.0)
                                {
                                    continue;
                                }
                            }
                            break;
                        }
                    }
                    else if (wpData.type == "RANDOM_WAYPOINT_NEAR")
                    {
                        Waypoint nearWaypoint = waypoints[wpData.nearIndex].waypoint;

                        LoggingUtil.LogVerbose(this, "   Generating a random waypoint near waypoint " + nearWaypoint.name + "...");

                        // TODO - this is really bad, we need to implement this method ourselves...
                        do
                        {
                            WaypointManager.ChooseRandomPositionNear(out wpData.waypoint.latitude, out wpData.waypoint.longitude,
                                                                     nearWaypoint.latitude, nearWaypoint.longitude, wpData.waypoint.celestialName,
                                                                     wpData.maxDistance, wpData.waterAllowed, random);

                            // Force a water waypoint
                            if (wpData.underwater)
                            {
                                Vector3d radialVector = QuaternionD.AngleAxis(wpData.waypoint.longitude, Vector3d.down) *
                                                        QuaternionD.AngleAxis(wpData.waypoint.latitude, Vector3d.forward) * Vector3d.right;
                                if (body.pqsController.GetSurfaceHeight(radialVector) - body.pqsController.radius >= 0.0)
                                {
                                    continue;
                                }
                            }
                        } while (WaypointUtil.GetDistance(wpData.waypoint.latitude, wpData.waypoint.longitude, nearWaypoint.latitude, nearWaypoint.longitude,
                                                          body.Radius) < wpData.minDistance);
                    }
                    else if (wpData.type == "PQS_CITY")
                    {
                        GeneratePQSCityCoordinates(wpData, body);
                    }

                    // Set altitude
                    SetAltitude(wpData, body);

                    LoggingUtil.LogVerbose(this, "   Generated waypoint " + wpData.waypoint.name + " at " +
                                           wpData.waypoint.latitude + ", " + wpData.waypoint.longitude + ".");
                }

                initialized = true;
                LoggingUtil.LogVerbose(this, "Waypoint generator initialized.");
            }
        }
Exemple #53
0
 private void Awake()
 {
     unitProperties  = this.gameObject.GetComponent <UnitProperties> ();
     wayPointManager = FindObjectOfType(typeof(WaypointManager)) as WaypointManager;
     gameManager     = FindObjectOfType(typeof(GameManager)) as GameManager;
 }
    private List<GameObject> wpList = new List<GameObject>(); //temporary list for editor created waypoints in a path

    #endregion Fields

    #region Methods

    //inspector input
    public override void OnInspectorGUI()
    {
        //show default variables of script "WaypointManager"
        DrawDefaultInspector();
        //get WaypointManager.cs reference
        script = (WaypointManager)target;

        //make the default styles used by EditorGUI look like controls
        EditorGUIUtility.LookLikeControls();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();

        //draw path text label
        GUILayout.Label("Enter Path Name: ", EditorStyles.boldLabel, GUILayout.Height(15));
        //display text field for creating a path with that name
        pathName = EditorGUILayout.TextField(pathName, GUILayout.Height(15));

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        //create new waypoint path button
        if (!placing && GUILayout.Button("Start Waypoint Path", GUILayout.Height(40)))
        {
            //no path name defined, abort with short editor warning
            if (pathName == "")
            {
                Debug.LogWarning("no path name defined");
                return;
            }

            //path name already given, abort with short editor warning
            if (script.transform.FindChild(pathName) != null)
            {
                Debug.LogWarning("path name already given");
                return;
            }

            //create a new container transform which will hold all new waypoints
            path = new GameObject(pathName);
            //attach PathManager component to this new waypoint container
            pathMan = path.AddComponent<PathManager>();
            //create waypoint array instance of PathManager
            pathMan.waypoints = new Transform[0];
            //reset position and parent container gameobject to this manager gameobject
            path.transform.position = script.gameObject.transform.position;
            path.transform.parent = script.gameObject.transform;
            //we passed all prior checks, toggle waypoint placing on
            placing = true;
            //fokus sceneview for placing new waypoints
            SceneView sceneView = (SceneView)SceneView.sceneViews[0];
            sceneView.Focus();
        } //finish path button

        //create new bezier path button
        if (!placing && GUILayout.Button("Start Bezier Path", GUILayout.Height(40)))
        {
            //same as above
            if (pathName == "")
            {
                Debug.LogWarning("no path name defined");
                return;
            }

            if (script.transform.FindChild(pathName) != null)
            {
                Debug.LogWarning("path name already given");
                return;
            }

            path = new GameObject(pathName);
            //attach BezierPathManager component to this new waypoint container
            bezierPathMan = path.AddComponent<BezierPathManager>();
            bezierPathMan.showGizmos = true;
            //create waypoint list instance of BezierPathManager
            bezierPathMan.points = new List<BezierPoint>();
            //reset position and parent container gameobject to this manager gameobject
            path.transform.position = script.gameObject.transform.position;
            path.transform.parent = script.gameObject.transform;
            //we passed all prior checks, toggle waypoint placing on
            placing = true;
            //fokus sceneview for placing new waypoints
            SceneView sceneView = (SceneView)SceneView.sceneViews[0];
            sceneView.Focus();
        }

        //finish path button
        if (placing && GUILayout.Button("Finish Editing", GUILayout.Height(40)))
        {
            //return if no path was started or not enough waypoints, so wpList/bwpList is empty
            if (pathMan && wpList.Count < 2 || bezierPathMan && bwpList.Count < 2)
            {
                Debug.LogWarning("not enough waypoints placed");

                //if we have created a path already, destroy it again
                if (path)
                    DestroyImmediate(path);
            }
            else if (pathMan)
            {
                //switch name of last created waypoint to waypointEnd,
                //so we will recognize this path ended (this gets an other editor gizmo)
                wpList[wpList.Count - 1].name = "WaypointEnd";
                //do the same with first waypoint
                wpList[0].name = "WaypointStart";
            }
            else if (bezierPathMan)
            {
                //do the same with the bezier path points in case they were used
                bwpList[bwpList.Count - 1].wp.name = "WaypointEnd";
                bwpList[0].wp.name = "WaypointStart";
            }

            //toggle placing off
            placing = false;

            //clear list with temporary waypoint references,
            //we only needed this list for getting first and last waypoint easily
            wpList.Clear();
            bwpList.Clear();
            //reset path name input field
            pathName = "";
            //make the new path the active selection
            Selection.activeGameObject = path;
        }

        EditorGUILayout.Space();

        GUILayout.Label("Hint:\nPress 'Start Path' to begin a new path," +
                        "\npress 'p' on your keyboard to place\nwaypoints onto objects with colliders." +
                        "\nPress 'Finish Editing' to end your path.");
    }
Exemple #55
0
        public void WaypointList()
        {
            if (PN == null)
            {
                return;
            }
            var WPM = WaypointManager.Instance();

            if (CFG.Path.Count == 0)
            {
                GUILayout.BeginHorizontal();
                if (TCAScenario.Paths.Count > 0)
                {
                    Utils.ButtonSwitch("Navigation Paths", ref show_path_library, "", GUILayout.ExpandWidth(true));
                }
                if (WPM != null && WPM.Waypoints.Count > 0)
                {
                    Utils.ButtonSwitch("Contract Waypoints", ref show_stock_waypoints, "", GUILayout.ExpandWidth(true));
                }
                GUILayout.EndHorizontal();
                stock_waypoints(WPM);
                path_library();
                return;
            }
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(CFG.ShowPath? "Hide Waypoints" : "Show Waypoints",
                                 Styles.active_button,
                                 GUILayout.ExpandWidth(true)))
            {
                CFG.ShowPath = !CFG.ShowPath;
            }
            if (TCAScenario.Paths.Empty)
            {
                GUILayout.Label("Load Path", Styles.inactive_button, GUILayout.ExpandWidth(false));
            }
            else
            {
                Utils.ButtonSwitch("Load Path", ref show_path_library, "", GUILayout.ExpandWidth(false));
            }
            if (WPM == null || WPM.Waypoints.Count == 0)
            {
                GUILayout.Label("Add From Contracts", Styles.inactive_button, GUILayout.ExpandWidth(false));
            }
            else
            {
                Utils.ButtonSwitch("Add From Contracts", ref show_stock_waypoints, "", GUILayout.ExpandWidth(false));
            }
            GUILayout.EndHorizontal();
            stock_waypoints(WPM);
            path_library();
            if (CFG.ShowPath)
            {
                GUILayout.BeginVertical(Styles.white);
                waypointsScroll = GUILayout
                                  .BeginScrollView(waypointsScroll,
                                                   GUILayout.Height(Utils.ClampH(TCAGui.LineHeight * (CFG.Path.Count + 1),
                                                                                 TCAGui.ControlsHeightHalf)));
                GUILayout.BeginVertical();
                int      i   = 0;
                var      num = (float)(CFG.Path.Count - 1);
                var      col = GUI.contentColor;
                WayPoint del = null;
                WayPoint up  = null;
                foreach (var wp in CFG.Path)
                {
                    GUI.contentColor = marker_color(i, num);
                    var label = string.Format("{0}) {1}", 1 + i, wp.GetName());
                    if (wp == edited_waypoint)
                    {
                        label += " *";
                    }
                    if (CFG.Target == wp)
                    {
                        var hd   = (float)wp.DistanceTo(vessel);
                        var vd   = (float)(wp.Pos.Alt - vessel.altitude);
                        var info = string.Format("Distance: ◀ {0} ▲ {1}",
                                                 Utils.formatBigValue(hd, "m"),
                                                 Utils.formatBigValue(vd, "m"));
                        if (VSL.HorizontalSpeed.Absolute > 0.1)
                        {
                            info += string.Format(", ETA {0:c}", new TimeSpan(0, 0, (int)(hd / VSL.HorizontalSpeed.Absolute)));
                        }
                        GUILayout.Label(info, Styles.white, GUILayout.ExpandWidth(true));
                    }
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent(label, string.Format("{0}\nPush to target this waypoint", wp.SurfaceDescription(vessel))),
                                         GUILayout.ExpandWidth(true)))
                    {
                        VSL.SetTarget(null, wp);
                    }
                    GUI.contentColor = col;
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Edit", Styles.normal_button))
                    {
                        edit_waypoint(wp);
                    }
                    if (GUILayout.Button(new GUIContent("^", "Move up"), Styles.normal_button))
                    {
                        up = wp;
                    }
                    if (LND != null &&
                        Utils.ButtonSwitch("Land", wp.Land, "Land on arrival"))
                    {
                        wp.Land = !wp.Land;
                    }
                    if (Utils.ButtonSwitch("||", wp.Pause, "Pause on arrival", GUILayout.Width(25)))
                    {
                        wp.Pause = !wp.Pause;
                    }
                    if (GUILayout.Button(new GUIContent("X", "Delete waypoint"),
                                         Styles.danger_button, GUILayout.Width(25)))
                    {
                        del = wp;
                    }
                    GUILayout.EndHorizontal();
                    i++;
                }
                GUI.contentColor = col;
                if (del != null)
                {
                    CFG.Path.Remove(del);
                }
                else if (up != null)
                {
                    CFG.Path.MoveUp(up);
                }
                if (CFG.Path.Count == 0 && CFG.Nav)
                {
                    CFG.HF.XOn(HFlight.Stop);
                }
                GUILayout.EndVertical();
                GUILayout.EndScrollView();
                GUILayout.BeginHorizontal();
                path_name = GUILayout.TextField(path_name, GUILayout.ExpandWidth(true));
                if (string.IsNullOrEmpty(path_name))
                {
                    GUILayout.Label("Save Path", Styles.inactive_button, GUILayout.Width(70));
                }
                else
                {
                    var existing = TCAScenario.Paths.Contains(path_name);
                    if (GUILayout.Button(existing? "Overwrite" : "Save Path",
                                         existing? Styles.danger_button : Styles.enabled_button,
                                         GUILayout.Width(70)))
                    {
                        CFG.Path.Name = path_name;
                        TCAScenario.Paths.SavePath(CFG.Path);
                    }
                }
                if (GUILayout.Button("Clear Path", Styles.danger_button, GUILayout.ExpandWidth(false)))
                {
                    CFG.Path.Clear();
                }
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
        }