Exemple #1
0
    private ShipBase SpawnPartyMember(MacroAIParty party, Loadout loadout)
    {
        ShipBase ship = GameManager.Inst.NPCManager.SpawnAIShip(loadout, party.FactionID, party);

        ship.transform.position = party.Location.RealPos + UnityEngine.Random.insideUnitSphere * 15f;
        party.SpawnedShips.Add(ship);
        AI ai = ship.GetComponent <AI>();

        ai.MyParty = party;
        if (ship.MyReference.ExhaustController != null)
        {
            ship.MyReference.ExhaustController.setExhaustState(ExhaustState.Normal);
        }

        if (party.SpawnedShipsLeader != null)
        {
            ai.Whiteboard.Parameters["FriendlyTarget"] = party.SpawnedShipsLeader;
        }
        ai.Deactivate();
        if (party.DockedStationID != "")
        {
            Debug.LogError("docked! at " + party.DockedStationID);
            ship.Hide();
            ai.IsDocked          = true;
            ship.DockedStationID = party.DockedStationID;
        }
        ship.name = "AIShip-" + (GameManager.Inst.NPCManager.AllShips.Count + 1);

        Debug.LogError("Spawning ship! " + ai.MyShip.name + " party " + party.PartyNumber);
        GameManager.Inst.NPCManager.AddExistingShip(ship);

        return(ship);
    }
Exemple #2
0
    // Use this for initialization
    public virtual void Initialize(MacroAIParty party, Faction faction)
    {
        RunningNodeHist = new MaxStack <string>(20);

        AimSkill                     = UnityEngine.Random.Range(0.6f, 1f);
        MyShip                       = transform.GetComponent <ShipBase>();
        AvoidanceDetector            = MyShip.MyReference.AvoidanceDetector;
        AvoidanceDetector.ParentShip = MyShip;

        Whiteboard = new Whiteboard();
        Whiteboard.Initialize();

        //AttackTarget = GameManager.Inst.PlayerControl.PlayerShip;

        //Whiteboard.Parameters["TargetEnemy"] = AttackTarget;
        Whiteboard.Parameters["SpeedLimit"] = -1f;

        MyParty       = party;
        MyFaction     = faction;
        MyPartyNumber = MyParty.PartyNumber;

        WeaponControl = new AIWeaponControl();
        WeaponControl.Initialize(this);

        TreeSet = new Dictionary <string, BehaviorTree>();
        TreeSet.Add("BaseBehavior", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("BaseBehavior", this, party));
        TreeSet.Add("Travel", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("Travel", this, party));
        TreeSet.Add("FollowFriendly", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("FollowFriendly", this, party));
        TreeSet.Add("FighterCombat", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("FighterCombat", this, party));
        TreeSet.Add("BigShipCombat", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("BigShipCombat", this, party));
    }
Exemple #3
0
 public void LoadPartyTreeset(MacroAIParty party)
 {
     party.TreeSet = new Dictionary <string, BehaviorTree>();
     party.TreeSet.Add("MAIBaseBehavior", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("MAIBaseBehavior", null, party));
     party.TreeSet.Add("MAITravel", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("MAITravel", null, party));
     party.TreeSet.Add("MAICombat", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("MAICombat", null, party));
 }
    public TLTransitSession(ShipBase leader, int direction, Tradelane currentTradelane)
    {
        Passengers = new List <ShipBase>();
        PassengerTargetRotations = new Dictionary <ShipBase, Quaternion>();
        PassengerTargetPositions = new Dictionary <ShipBase, RelLoc>();
        Party           = leader.MyAI.MyParty;
        LeaderPassenger = leader;

        Direction        = direction;
        Stage            = TLSessionStage.None;
        CurrentTradelane = currentTradelane;

        if (Direction == -1)
        {
            CurrentTrigger = CurrentTradelane.TriggerA;
        }
        else
        {
            CurrentTrigger = CurrentTradelane.TriggerB;
        }

        if (leader == GameManager.Inst.PlayerControl.PlayerShip)
        {
            GameManager.Inst.PlayerControl.CurrentTradelaneSession = this;
        }
    }
Exemple #5
0
    private void TradeCommodity(MacroAIParty party, DockableStationData stationData)
    {
        //check if there are any commodity goods in leader's cargo bay. if so, check if station is in demand for it
        //if so, sell it and trigger economy event. if demand level is less than 1, only a certain probability will sell it
        List <InvItemData> cargoCopy = new List <InvItemData>(party.LeaderLoadout.CargoBayItems);

        foreach (InvItemData invItem in cargoCopy)
        {
            if (invItem.Item.Type == ItemType.Commodity)
            {
                ResourceType resourceType = invItem.Item.GetResourceTypeAttribute();
                foreach (DemandResource demand in stationData.DemandResources)
                {
                    if (demand.Type == resourceType || demand.ItemID == invItem.Item.ID)
                    {
                        float sellProbability = 1;
                        if (demand.CurrentDemand <= 1)
                        {
                            sellProbability = 0.4f;
                        }

                        if (UnityEngine.Random.value < sellProbability)
                        {
                            party.LeaderLoadout.CargoBayItems.Remove(invItem);
                            GameManager.Inst.EconomyManager.OnConvoySellCommodity(stationData, resourceType, invItem.Quantity);
                        }
                    }
                }
            }
        }

        //check if leader cargobay has room. if so, check if station has any commodity for sale and supply level is above 1
        //if so buy it and trigger economy event. if supply level is less than 1, only a certain probability will buy it
        float cargoBayUsage = party.LeaderLoadout.GetCargoBayUsage();
        float cargoBaySize  = GameManager.Inst.ItemManager.GetShipStats(party.LeaderLoadout.ShipID).CargoBaySize;

        foreach (SaleItem saleItem in stationData.TraderSaleItems)
        {
            ItemStats stats = GameManager.Inst.ItemManager.GetItemStats(saleItem.ItemID);
            if (stats.Type == ItemType.Commodity)
            {
                float buyProbability = 1;
                if (saleItem.SupplyLevel <= 1)
                {
                    buyProbability = 0.4f;
                }

                if (UnityEngine.Random.value < buyProbability && cargoBayUsage < cargoBaySize)
                {
                    InvItemData itemData = new InvItemData();
                    Item        item     = new Item(GameManager.Inst.ItemManager.GetItemStats(saleItem.ItemID));
                    itemData.Item     = item;
                    itemData.Quantity = UnityEngine.Random.Range(1, Mathf.FloorToInt(cargoBaySize - cargoBayUsage));
                    GameManager.Inst.ItemManager.AddItemtoInvItemDataList(party.LeaderLoadout.CargoBayItems, itemData, itemData.Quantity);
                    GameManager.Inst.EconomyManager.OnConvoyBuyCommodity(stationData, itemData.Item.ID, itemData.Quantity);
                }
            }
        }
    }
    public void GenerateTraderParty(string factionID)
    {
        MacroAIParty party = new MacroAIParty();

        party.FactionID    = factionID;
        party.SpawnedShips = new List <ShipBase>();

        Faction faction = GameManager.Inst.NPCManager.AllFactions[party.FactionID];

        List <string> keyList = new List <string>(GameManager.Inst.WorldManager.AllSystems.Keys);

        //StarSystemData currentSystem = GameManager.Inst.WorldManager.AllSystems["washington_system"];
        //StarSystemData currentSystem = GameManager.Inst.WorldManager.AllSystems[keyList[UnityEngine.Random.Range(0, keyList.Count)]];
        StationData    currentStation = GameManager.Inst.WorldManager.GetRandomFriendlyDockableStation(party.FactionID, null);
        StarSystemData currentSystem  = GameManager.Inst.WorldManager.AllSystems[currentStation.SystemID];

        party.CurrentSystemID = currentSystem.ID;

        //StationData currentStation = currentSystem.GetStationByID("planet_colombia_landing");
        //StationData currentStation = currentSystem.Stations[UnityEngine.Random.Range(0, currentSystem.Stations.Count)];
        party.DockedStationID = currentStation.ID;
        Transform origin = GameObject.Find("Origin").transform;

        party.Location    = new RelLoc(origin.position, currentStation.Location.RealPos, origin);
        party.PartyNumber = GameManager.Inst.NPCManager.LastUsedPartyNumber + 1;
        GameManager.Inst.NPCManager.LastUsedPartyNumber = party.PartyNumber;

        //pick 1 freighter loadout for the leader
        if (faction.FreightersPool.Count > 0)
        {
            party.LeaderLoadout = new Loadout(faction.FreightersPool[UnityEngine.Random.Range(0, faction.FreightersPool.Count)]);
        }
        else
        {
            party.LeaderLoadout = new Loadout(faction.FightersPool[UnityEngine.Random.Range(0, faction.FightersPool.Count)]);
        }

        //pick 1-4 fighter loadouts for followers
        party.FollowerLoadouts = new List <Loadout>();
        int numberOfFollowers = UnityEngine.Random.Range(1, 5);

        for (int i = 0; i < numberOfFollowers; i++)
        {
            party.FollowerLoadouts.Add(new Loadout(faction.FightersPool[UnityEngine.Random.Range(0, faction.FightersPool.Count)]));
        }

        MacroAITask task = GameManager.Inst.NPCManager.MacroAI.AssignMacroAITask(MacroAITaskType.None, party);

        party.IsInTradelane = false;
        //party.DestinationCoord = GameManager.Inst.WorldManager.AllNavNodes["cambridge_station"].Location;
        party.MoveSpeed    = 10f;
        party.NextTwoNodes = new List <NavNode>();
        party.PrevNode     = null;    //CreateTempNode(party.Location, "tempstart", GameManager.Inst.WorldManager.AllSystems[party.CurrentSystemID]);

        GameManager.Inst.NPCManager.MacroAI.LoadPartyTreeset(party);

        GameManager.Inst.NPCManager.AllParties.Add(party);
    }
Exemple #7
0
 public void CreatePlayerParty()
 {
     Debug.Log("Creating player party");
     //create MacroAIParty for player
     PlayerParty     = GameManager.Inst.NPCManager.MacroAI.GeneratePlayerParty();
     PlayerAutopilot = PlayerShip.GetComponent <Autopilot>();
     PlayerAutopilot.Initialize(PlayerParty, GameManager.Inst.NPCManager.AllFactions["player"]);
     Debug.Log("Creating player party DONE");
 }
Exemple #8
0
    public ShipBase SpawnPlayerShip(Loadout loadout, string factionID, MacroAIParty party)
    {
        ShipBase ship = GameManager.Inst.PlayerControl.PlayerShip;

        BuildShip(ship, loadout, factionID, party);

        Autopilot pilot = GameManager.Inst.PlayerControl.PlayerAutopilot;

        pilot.AvoidanceDetector            = ship.MyReference.AvoidanceDetector;
        pilot.AvoidanceDetector.ParentShip = ship;


        //load weapons
        foreach (WeaponJoint joint in ship.MyReference.WeaponJoints)
        {
            joint.ParentShip = ship;
            foreach (KeyValuePair <string, InvItemData> jointSetup in loadout.WeaponJoints)
            {
                if (jointSetup.Key == joint.JointID && jointSetup.Value != null)
                {
                    joint.LoadWeapon(jointSetup.Value);
                }
            }
        }

        for (int i = 0; i < loadout.Defensives.Count; i++)
        {
            if (loadout.Defensives[i] != null && loadout.Defensives[i].Item.GetStringAttribute("Defensive Type") == "Countermeasure")
            {
                CMDispenser dispenser = new CMDispenser();
                dispenser.ParentShip = ship;
                dispenser.AmmoID     = loadout.Defensives[i].RelatedItemID;
                dispenser.Type       = DefensiveType.Countermeasure;
                ship.MyReference.Defensives.Add(dispenser);
            }
        }

        //load ammo bay
        ship.Storage.AmmoBayItems = new Dictionary <string, InvItemData>();
        foreach (InvItemData item in loadout.AmmoBayItems)
        {
            ship.Storage.AmmoBayItems.Add(item.Item.ID, item);
        }

        ship.Storage.CargoBayItems = new List <InvItemData>();
        foreach (InvItemData item in loadout.CargoBayItems)
        {
            ship.Storage.CargoBayItems.Add(item);
        }
        //In$8177BB
        //load power management setting
        ship.CurrentPowerMgmtButton = loadout.CurrentPowerMgmtButton;


        return(ship);
    }
Exemple #9
0
    public void BuildShip(ShipBase ship, Loadout loadout, string factionID, MacroAIParty party)
    {
        string   shipModelID = loadout.ShipID;
        ShipType shipType    = loadout.ShipType;

        GameObject shipModel = GameObject.Instantiate(Resources.Load(shipModelID)) as GameObject;
        ShipStats  stats     = GameManager.Inst.ItemManager.GetShipStats(shipModelID);

        shipModel.transform.parent           = ship.transform;
        shipModel.transform.localScale       = new Vector3(1, 1, 1);
        shipModel.transform.localPosition    = Vector3.zero;
        shipModel.transform.localEulerAngles = Vector3.zero;
        ship.ShipModel              = shipModel;
        ship.ShipModelID            = shipModelID;
        ship.MyReference            = shipModel.GetComponent <ShipReference>();
        ship.MyReference.ParentShip = ship;
        ship.MyReference.Defensives = new List <Defensive>();
        ship.MyReference.ShipAudio  = ship.GetComponent <AudioSource>();
        ship.HullCapacity           = stats.Hull;
        ship.HullAmount             = loadout.HullAmount;
        ship.MaxFuel           = stats.MaxFuel;
        ship.FuelAmount        = loadout.FuelAmount;
        ship.MaxLifeSupport    = stats.LifeSupport;
        ship.LifeSupportAmount = loadout.LifeSupportAmount;
        ship.PowerSupply       = stats.PowerSupply;
        ship.TorqueModifier    = stats.TurnRate;
        ship.PowerSupply       = stats.PowerSupply;
        ship.ShieldPowerAlloc  = 1;
        ship.WeaponPowerAlloc  = 1;
        ship.EnginePowerAlloc  = 1;
        ship.Shield            = ship.MyReference.Shield.GetComponent <ShieldBase>();
        ship.Shield.Initialize(loadout.Shield);
        ship.Shield.ParentShip = ship;
        ship.RB = ship.GetComponent <Rigidbody>();
        ship.RB.inertiaTensor = new Vector3(1, 1, 1);
        ship.Engine           = shipModel.GetComponent <Engine>();
        ship.Engine.Initialize(stats);
        ship.Thruster = shipModel.GetComponent <Thruster>();
        ship.Thruster.Initialize(loadout.Thruster);
        ship.Scanner = shipModel.GetComponent <Scanner>();
        ship.Scanner.Initialize(loadout.Scanner);
        ship.Storage = shipModel.GetComponent <ShipStorage>();
        ship.Storage.Initialize();
        ship.Storage.AmmoBaySize  = stats.AmmoBaySize;
        ship.Storage.CargoBaySize = stats.CargoBaySize;
        ship.WeaponCapacitor      = shipModel.GetComponent <WeaponCapacitor>();
        ship.WeaponCapacitor.Initialize(loadout.WeaponCapacitor);

        ship.ShipModSlots = shipModel.GetComponent <ShipModSlots>();
        ship.ShipModSlots.NumberOfSlots = stats.ModSlots;
        ship.ShipModSlots.Initialize(loadout.ShipMods, ship);
        ship.ShipModSlots.ApplyMods();


        ship.MyLoadout = loadout;
    }
Exemple #10
0
 private void SpawnPartyMembers(MacroAIParty party)
 {
     if (!party.IsPlayerParty)
     {
         party.SpawnedShipsLeader = SpawnPartyMember(party, party.LeaderLoadout);
     }
     foreach (Loadout loadOut in party.FollowerLoadouts)
     {
         SpawnPartyMember(party, loadOut);
     }
 }
Exemple #11
0
    public MacroAIParty GeneratePlayerParty()
    {
        MacroAIParty party = new MacroAIParty();

        party.FactionID    = "player";
        party.SpawnedShips = new List <ShipBase>();
        party.SpawnedShips.Add(GameManager.Inst.PlayerControl.PlayerShip);
        party.IsPlayerParty = true;

        StarSystemData currentSystem = GameManager.Inst.WorldManager.AllSystems[GameManager.Inst.WorldManager.CurrentSystem.ID];

        party.CurrentSystemID = currentSystem.ID;
        StationData currentStation = null;

        party.DockedStationID = "";
        Transform origin = GameObject.Find("Origin").transform;

        party.Location           = new RelLoc(origin.position, GameManager.Inst.PlayerControl.PlayerShip.transform.position, origin);
        party.PartyNumber        = 0;
        party.SpawnedShipsLeader = GameManager.Inst.PlayerControl.PlayerShip;
        party.ShouldEnableAI     = true;

        //generate loadout
        party.LeaderLoadout = GameManager.Inst.PlayerProgress.ActiveLoadout;

        party.FollowerLoadouts = new List <Loadout>();

        /*
         * for(int i=0; i<4; i++)
         * {
         *      Loadout loadout = new Loadout("LightFighter", ShipType.Fighter);
         *      party.FollowerLoadouts.Add(loadout);
         *      loadout.WeaponJoints = new Dictionary<string, string>()
         *      {
         *              { "GimballLeft", "Gun1" },
         *              { "GimballRight", "Gun1" },
         *      };
         * }*/

        MacroAITask task = null;

        party.IsInTradelane = false;
        //party.DestinationCoord = GameManager.Inst.WorldManager.AllNavNodes["cambridge_station"].Location;
        party.MoveSpeed    = 10f;
        party.NextTwoNodes = new List <NavNode>();
        party.PrevNode     = null;    //CreateTempNode(party.Location, "tempstart", GameManager.Inst.WorldManager.AllSystems[party.CurrentSystemID]);

        LoadPartyTreeset(party);
        GenerateFormationForParty(party);

        GameManager.Inst.NPCManager.AllParties.Add(party);

        return(party);
    }
Exemple #12
0
    public ShipBase SpawnAIShip(Loadout loadout, string factionID, MacroAIParty party)
    {
        ShipBase ship = (GameObject.Instantiate(Resources.Load("AIShip")) as GameObject).GetComponent <ShipBase>();

        BuildShip(ship, loadout, factionID, party);



        //load weapons
        foreach (WeaponJoint joint in ship.MyReference.WeaponJoints)
        {
            joint.ParentShip = ship;
            foreach (KeyValuePair <string, InvItemData> jointSetup in loadout.WeaponJoints)
            {
                if (jointSetup.Key == joint.JointID)
                {
                    joint.LoadWeapon(jointSetup.Value);
                }
            }
        }

        for (int i = 0; i < loadout.Defensives.Count; i++)
        {
            if (loadout.Defensives[i] != null && loadout.Defensives[i].Item.GetStringAttribute("Defensive Type") == "Countermeasure")
            {
                CMDispenser dispenser = new CMDispenser();
                dispenser.ParentShip = ship;
                dispenser.AmmoID     = loadout.Defensives[i].RelatedItemID;
                dispenser.Type       = DefensiveType.Countermeasure;
                ship.MyReference.Defensives.Add(dispenser);
            }
        }

        //load ammo bay
        ship.Storage.AmmoBayItems = new Dictionary <string, InvItemData>();
        foreach (InvItemData item in loadout.AmmoBayItems)
        {
            ship.Storage.AmmoBayItems.Add(item.Item.ID, item);
        }
        ship.Storage.CargoBayItems = new List <InvItemData>();
        foreach (InvItemData item in loadout.CargoBayItems)
        {
            ship.Storage.CargoBayItems.Add(item);
        }

        AI ai = ship.GetComponent <AI>();

        ai.Initialize(party, _allFactions[factionID]);

        return(ship);
    }
Exemple #13
0
    public void OnShipDeath(ShipBase ship)
    {
        MacroAIParty party = ship.MyAI.MyParty;

        if (party.SpawnedShipsLeader == ship)
        {
            //elect a new leader
            party.SpawnedShips.Remove(ship);
            if (party.Formation.ContainsKey(ship))
            {
                party.Formation.Remove(ship);
            }
            party.LeaderLoadout = null;

            if (party.SpawnedShips.Count > 0)
            {
                //randomly pick one ship
                ShipBase candidate = party.SpawnedShips[UnityEngine.Random.Range(0, party.SpawnedShips.Count)];
                party.SpawnedShipsLeader   = candidate;
                party.Formation[candidate] = Vector3.zero;
                party.LeaderLoadout        = candidate.MyLoadout;
                if (party.FollowerLoadouts.Contains(candidate.MyLoadout))
                {
                    party.FollowerLoadouts.Remove(candidate.MyLoadout);
                }
            }
            else
            {
                //party is gone, remove party
                GameManager.Inst.NPCManager.AllParties.Remove(party);
            }
        }
        else if (party.SpawnedShips.Contains(ship))
        {
            //remove from spawned ships
            party.SpawnedShips.Remove(ship);
            //remove from formation
            if (party.Formation.ContainsKey(ship))
            {
                party.Formation.Remove(ship);
            }
            //remove from loadouts
            if (ship.MyLoadout != null && party.FollowerLoadouts.Contains(ship.MyLoadout))
            {
                party.FollowerLoadouts.Remove(ship.MyLoadout);
            }
        }
    }
Exemple #14
0
    private void DespawnParty(MacroAIParty party)
    {
        Debug.Log("Despawning party!");
        List <ShipBase> spawnedShipsCopy = new List <ShipBase>(party.SpawnedShips);

        foreach (ShipBase ship in spawnedShipsCopy)
        {
            GameManager.Inst.NPCManager.RemoveExistingShip(ship);
            party.SpawnedShips.Remove(ship);
            ship.GetComponent <AI>().Deactivate();
            GameObject.Destroy(ship.gameObject);
        }

        party.SpawnedShipsLeader = null;
        party.ShouldEnableAI     = false;
    }
Exemple #15
0
    public override void Initialize(MacroAIParty party, Faction faction)
    {
        RunningNodeHist = new MaxStack <string>(20);
        MyShip          = transform.GetComponent <ShipBase>();


        Whiteboard = new Whiteboard();
        Whiteboard.Initialize();

        //AttackTarget = GameManager.Inst.PlayerControl.PlayerShip;

        //Whiteboard.Parameters["TargetEnemy"] = AttackTarget;
        Whiteboard.Parameters["SpeedLimit"] = -1f;

        MyParty   = party;
        MyFaction = faction;

        TreeSet = new Dictionary <string, BehaviorTree>();
        TreeSet.Add("BaseBehavior", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("BaseBehavior", this, party));
        TreeSet.Add("APTravel", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("APTravel", this, party));
        TreeSet.Add("FollowFriendly", GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree("FollowFriendly", this, party));
    }
Exemple #16
0
    public BehaviorTree LoadBehaviorTree(string treeName, AI owner, MacroAIParty party)
    {
        XmlDocument xmlDoc = new XmlDocument();
        string      path   = Application.dataPath + "/GameData/BehaviorTree/";
        string      file   = File.ReadAllText(path + treeName + ".xml");

        try
        {
            xmlDoc.LoadXml(file);
        }
        catch (XmlException)
        {
            return(null);
        }
        _currentXML = xmlDoc;
        XmlNodeList  root = _currentXML.GetElementsByTagName("behavior");
        BehaviorTree tree = new BehaviorTree();

        tree.Name     = treeName;
        tree.RootNode = LoadBTNode(root[0], owner, party);
        //Debug.Log("Is Root null " + (tree.RootNode == null));
        return(tree);
    }
Exemple #17
0
    private void GenerateFormationForParty(MacroAIParty party)
    {
        party.Formation = new Dictionary <ShipBase, Vector3>();
        int currentTier = 1;
        int i           = 0;

        foreach (ShipBase ship in party.SpawnedShips)
        {
            if (party.SpawnedShipsLeader == ship)
            {
                continue;
            }
            Vector3 disp  = Vector3.zero + currentTier * new Vector3(0, 0, -7f);
            float   width = 3f;
            if (i == 0)
            {
                disp.y = 1 * width;
            }
            else if (i == 1)
            {
                disp.x = -1 * width;
            }
            else if (i == 2)
            {
                disp.y = -1 * width;
            }
            else if (i == 3)
            {
                disp.x = 1 * width;
                i      = 0;
                currentTier++;
            }
            i++;
            party.Formation.Add(ship, disp);
        }
    }
Exemple #18
0
    public void LoadWorldData()
    {
        GameManager.Inst.NPCManager.LastUsedPartyNumber = CurrentSave.LastUsedPartyNumber;

        //loading all NPC and player parties
        Debug.Log("Loading AI Parties, there are " + CurrentSave.AllNonPlayerParties.Count);
        foreach (MacroAIPartySaveData partyData in CurrentSave.AllNonPlayerParties)
        {
            Debug.Log("Loading Party " + partyData.PartyNumber);
            MacroAIParty party = new MacroAIParty();
            party.FactionID    = partyData.FactionID;
            party.SpawnedShips = new List <ShipBase>();

            //List<string> keyList = new List<string>(GameManager.Inst.WorldManager.AllSystems.Keys);
            StarSystemData currentSystem = GameManager.Inst.WorldManager.AllSystems[partyData.CurrentSystemID];
            party.CurrentSystemID = currentSystem.ID;
            party.DockedStationID = partyData.DockedStationID;

            if (GameManager.Inst.WorldManager.CurrentSystem != null && currentSystem.ID == GameManager.Inst.WorldManager.CurrentSystem.ID)
            {
                party.Location = new RelLoc(currentSystem.OriginPosition, partyData.Location.ConvertToVector3(), GameObject.Find("Origin").transform, 1);
            }
            else
            {
                party.Location = new RelLoc(currentSystem.OriginPosition, partyData.Location.ConvertToVector3(), null, 1);
            }
            party.PartyNumber = partyData.PartyNumber;

            //generate loadout
            party.LeaderLoadout = LoadLoadoutFromSave(partyData.LeaderLoadout);


            party.FollowerLoadouts = new List <Loadout>();
            foreach (LoadoutSaveData loadoutData in partyData.FollowerLoadouts)
            {
                Loadout loadout = LoadLoadoutFromSave(loadoutData);
                party.FollowerLoadouts.Add(loadout);
            }


            if (partyData.CurrentTask != null)
            {
                MacroAITask task = new MacroAITask();
                task.IsDestAStation = partyData.CurrentTask.IsDestAStation;
                task.StayDuration   = partyData.CurrentTask.StayDuration;
                task.TaskType       = partyData.CurrentTask.TaskType;

                if (partyData.CurrentTask.TravelDestCoord != null)
                {
                    if (currentSystem.ID == GameManager.Inst.WorldManager.CurrentSystem.ID)
                    {
                        task.TravelDestCoord = new RelLoc(currentSystem.OriginPosition, partyData.CurrentTask.TravelDestCoord.ConvertToVector3(), GameObject.Find("Origin").transform, 1);
                    }
                    else
                    {
                        task.TravelDestCoord = new RelLoc(currentSystem.OriginPosition, partyData.CurrentTask.TravelDestCoord.ConvertToVector3(), null, 1);
                    }
                }
                task.TravelDestNodeID   = partyData.CurrentTask.TravelDestNodeID;
                task.TravelDestSystemID = partyData.CurrentTask.TravelDestSystemID;
                Debug.Log("Loading task type " + task.TaskType.ToString() + " " + task.TravelDestNodeID);
                party.CurrentTask = task;

                if (party.CurrentTask.TaskType == MacroAITaskType.Travel)
                {
                    if (party.CurrentTask.IsDestAStation)
                    {
                        party.DestNode = GameManager.Inst.WorldManager.AllNavNodes[party.CurrentTask.TravelDestNodeID];
                    }
                    else
                    {
                        //party.DestNode = CreateTempNode(party.CurrentTask.TravelDestCoord, "tempdest", GameManager.Inst.WorldManager.AllSystems[party.CurrentTask.TravelDestSystemID]);
                        party.DestNode = GameManager.Inst.NPCManager.MacroAI.GetClosestNodeToLocation(party.CurrentTask.TravelDestCoord.RealPos, GameManager.Inst.WorldManager.AllSystems[party.CurrentTask.TravelDestSystemID]);
                    }
                }
            }


            party.IsInTradelane = partyData.IsInTradelane;
            party.MoveSpeed     = partyData.MoveSpeed;
            party.NextTwoNodes  = new List <NavNode>();
            foreach (string nodeID in partyData.NextTwoNodesIDs)
            {
                Debug.Log("Next node " + nodeID);
                party.NextTwoNodes.Add(GameManager.Inst.WorldManager.AllNavNodes[nodeID]);
            }
            if (partyData.PrevNodeID != "")
            {
                party.PrevNode = GameManager.Inst.WorldManager.AllNavNodes[partyData.PrevNodeID];
            }
            party.TreeSet = new Dictionary <string, BehaviorTree>();
            foreach (string treeSetName in partyData.TreeSetNames)
            {
                party.TreeSet.Add(treeSetName, GameManager.Inst.DBManager.XMLParserBT.LoadBehaviorTree(treeSetName, null, party));
            }


            GameManager.Inst.NPCManager.AllParties.Add(party);
        }

        //load station data
        GameManager.Inst.WorldManager.DockableStationDatas = new Dictionary <string, DockableStationData>();
        foreach (DockableStationSaveData saveData in CurrentSave.DockableStationDatas)
        {
            DockableStationData stationData = new DockableStationData();
            stationData.DemandResources = saveData.DemandResources;
            stationData.DockedParties   = new List <MacroAIParty>();
            foreach (int partyNumber in saveData.DockedPartiesNumbers)
            {
                stationData.DockedParties.Add(GameManager.Inst.NPCManager.GetPartyByNumber(partyNumber));
            }
            stationData.FuelPrice                    = saveData.FuelPrice;
            stationData.LifeSupportPrice             = saveData.LifeSupportPrice;
            stationData.ShipsForSale                 = saveData.ShipsForSale;
            stationData.StationID                    = saveData.StationID;
            stationData.FactionID                    = saveData.FactionID;
            stationData.TraderSaleItems              = saveData.TraderSaleItems;
            stationData.UndesiredItemPriceMultiplier = saveData.UndesiredItemPriceMultiplier;
            stationData.DemandNormalizeSpeed         = saveData.DemandNormalizeSpeed;
            if (saveData.HomeStationSaveData != null)
            {
                stationData.HomeStationData               = new HomeStationData();
                stationData.HomeStationData.HangarSize    = saveData.HomeStationSaveData.HangarSize;
                stationData.HomeStationData.VaultSize     = saveData.HomeStationSaveData.VaultSize;
                stationData.HomeStationData.ItemsInVault  = saveData.HomeStationSaveData.ItemsInVault;
                stationData.HomeStationData.ShipsInHangar = new List <Loadout>();
                foreach (LoadoutSaveData loadoutSaveData in saveData.HomeStationSaveData.ShipsInHangar)
                {
                    stationData.HomeStationData.ShipsInHangar.Add(LoadLoadoutFromSave(loadoutSaveData));
                }
            }

            GameManager.Inst.WorldManager.DockableStationDatas.Add(stationData.StationID, stationData);
        }

        //load time
        GameManager.Inst.WorldManager.CurrentTime = CurrentSave.CurrentTime;
    }
Exemple #19
0
    private BTNode LoadBTNode(XmlNode currentNode, AI owner, MacroAIParty party)
    {
        XmlNodeList nodeContent = currentNode.ChildNodes;

        XmlAttributeCollection nodeAttributes = currentNode.Attributes;
        BTNode node = null;

        if (currentNode.Name == "behavior")
        {
            node = LoadBTNode(nodeContent[0], owner, party);
        }
        else if (currentNode.Name == "composite")
        {
            BTComposite compNode = null;
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Sequence")
            {
                BTSequence seqNode = new BTSequence();
                seqNode.CompNodeType = BTCompType.Sequence;
                compNode             = seqNode;
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Selector")
            {
                BTSelector selNode = new BTSelector();
                selNode.CompNodeType = BTCompType.Selector;
                compNode             = selNode;
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "ParallelAnd")
            {
                BTParallelAnd parNode = new BTParallelAnd();
                parNode.CompNodeType = BTCompType.ParallelAnd;
                compNode             = parNode;
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "ParallelMain")
            {
                BTParallelMain parNode = new BTParallelMain();
                parNode.CompNodeType = BTCompType.ParallelMain;
                compNode             = parNode;
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Random")
            {
                BTRandom randNode = new BTRandom();
                randNode.CompNodeType = BTCompType.Random;
                compNode = randNode;
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Switch")
            {
                BTSwitch swNode = new BTSwitch();
                swNode.CompNodeType = BTCompType.Switch;
                compNode            = swNode;
            }

            compNode.Children = new List <BTNode>();

            foreach (XmlNode nodeItem in nodeContent)
            {
                compNode.Children.Add(LoadBTNode(nodeItem, owner, party));
            }

            node = compNode;
        }
        else if (currentNode.Name == "decorator")
        {
            BTDecorator decNode = null;
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Repeat")
            {
                BTRepeat repNode = new BTRepeat();
                decNode = repNode;
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Invert")
            {
                BTInvert invNode = new BTInvert();
                decNode = invNode;
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "UntilFail")
            {
                BTUntilFail repNode = new BTUntilFail();
                decNode = repNode;
            }
            foreach (XmlNode nodeItem in nodeContent)
            {
                decNode.Child = LoadBTNode(nodeItem, owner, party);
            }

            node = decNode;
        }
        else if (currentNode.Name == "leaf")
        {
            XmlNodeList   parameterList = currentNode.ChildNodes;
            List <string> parameters    = new List <string>();
            foreach (XmlNode paramNode in parameterList)
            {
                parameters.Add(paramNode.InnerText);
            }

            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Check")
            {
                if (nodeAttributes["name"] != null)
                {
                    string  actionName = nodeAttributes["name"].Value;
                    BTCheck checkNode  = new BTCheck();
                    checkNode.Action     = actionName;
                    checkNode.Parameters = parameters;
                    checkNode.MyAI       = owner;
                    checkNode.MyParty    = party;
                    node = checkNode;
                }
            }
            if (nodeAttributes["type"] != null && nodeAttributes["type"].Value == "Action")
            {
                if (nodeAttributes["name"] != null)
                {
                    BTLeaf leafNode = (BTLeaf)System.Activator.CreateInstance(System.Type.GetType("BT" + nodeAttributes["name"].Value));
                    leafNode.Parameters = parameters;
                    leafNode.MyAI       = owner;
                    leafNode.MyParty    = party;
                    node = leafNode;
                }
            }
        }

        return(node);
    }
Exemple #20
0
    public void GenerateTestParty(string factionID)
    {
        MacroAIParty party = new MacroAIParty();

        party.FactionID    = factionID;
        party.SpawnedShips = new List <ShipBase>();

        List <string> keyList = new List <string>(GameManager.Inst.WorldManager.AllSystems.Keys);

        //StarSystemData currentSystem = GameManager.Inst.WorldManager.AllSystems["washington_system"];
        StarSystemData currentSystem = GameManager.Inst.WorldManager.AllSystems[keyList[UnityEngine.Random.Range(0, keyList.Count)]];

        party.CurrentSystemID = currentSystem.ID;

        //StationData currentStation = currentSystem.GetStationByID("planet_colombia_landing");
        StationData currentStation = currentSystem.Stations[UnityEngine.Random.Range(0, currentSystem.Stations.Count)];

        party.DockedStationID = "planet_colombia_landing";
        Transform origin = GameObject.Find("Origin").transform;

        party.Location    = new RelLoc(origin.position, currentStation.Location.RealPos, origin);
        party.PartyNumber = GameManager.Inst.NPCManager.LastUsedPartyNumber + 1;
        GameManager.Inst.NPCManager.LastUsedPartyNumber = party.PartyNumber;

        Item        item1     = new Item(GameManager.Inst.ItemManager.GetItemStats("wc_VikoWeaponCapacitorMK1"));
        InvItemData itemData1 = new InvItemData();

        itemData1.Item     = item1;
        itemData1.Quantity = 1;


        Item        item2     = new Item(GameManager.Inst.ItemManager.GetItemStats("scn_RadianTekShortRangeScanner"));
        InvItemData itemData2 = new InvItemData();

        itemData2.Item     = item2;
        itemData2.Quantity = 1;


        Item        item3     = new Item(GameManager.Inst.ItemManager.GetItemStats("thr_StrelskyThrusterMK1"));
        InvItemData itemData3 = new InvItemData();

        itemData3.Item     = item3;
        itemData3.Quantity = 1;


        Item        item4     = new Item(GameManager.Inst.ItemManager.GetItemStats("shd_NCPTransporterShieldMK1"));
        InvItemData itemData4 = new InvItemData();

        itemData4.Item     = item4;
        itemData4.Quantity = 1;


        Item        item5     = new Item(GameManager.Inst.ItemManager.GetItemStats("dfs_CMDispenser"));
        InvItemData itemData5 = new InvItemData();

        itemData5.Item          = item5;
        itemData5.Quantity      = 1;
        itemData5.RelatedItemID = "ammo_LongDurationCM";


        Item        item10     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_SDCStomperAutocannon"));
        InvItemData itemData10 = new InvItemData();

        itemData10.Item          = item10;
        itemData10.Quantity      = 1;
        itemData10.RelatedItemID = "ammo_20mmTitaniumSlugs";


        Item        item11     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_StrelskyScreamerMissileLauncher"));
        InvItemData itemData11 = new InvItemData();

        itemData11.Item          = item11;
        itemData11.Quantity      = 1;
        itemData11.RelatedItemID = "ammo_StrelskySeekerMissile";


        Item        item12     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_AlFasadIonFluxTurretMK1"));
        InvItemData itemData12 = new InvItemData();

        itemData12.Item     = item12;
        itemData12.Quantity = 1;


        Item        item13     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_CGGAnnihilatorTurretMK2"));
        InvItemData itemData13 = new InvItemData();

        itemData13.Item     = item13;
        itemData13.Quantity = 1;


        Item        item14     = new Item(GameManager.Inst.ItemManager.GetItemStats("shd_KeslerFighterShieldMK1"));
        InvItemData itemData14 = new InvItemData();

        itemData14.Item     = item14;
        itemData14.Quantity = 1;

        Item        item15     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_AlFasadStingerPulseCannon"));
        InvItemData itemData15 = new InvItemData();

        itemData15.Item     = item15;
        itemData15.Quantity = 1;


        Item        item20     = new Item(GameManager.Inst.ItemManager.GetItemStats("ammo_LongDurationCM"));
        InvItemData itemData20 = new InvItemData();

        itemData20.Item     = item20;
        itemData20.Quantity = UnityEngine.Random.Range(1, 3);


        Item        item21     = new Item(GameManager.Inst.ItemManager.GetItemStats("ammo_20mmTitaniumSlugs"));
        InvItemData itemData21 = new InvItemData();

        itemData21.Item     = item21;
        itemData21.Quantity = 500;


        Item        item101     = new Item(GameManager.Inst.ItemManager.GetItemStats("wc_VikoWeaponCapacitorMK1"));
        InvItemData itemData101 = new InvItemData();

        itemData101.Item     = item101;
        itemData101.Quantity = 1;


        Item        item102     = new Item(GameManager.Inst.ItemManager.GetItemStats("scn_RadianTekShortRangeScanner"));
        InvItemData itemData102 = new InvItemData();

        itemData102.Item     = item102;
        itemData102.Quantity = 1;


        Item        item103     = new Item(GameManager.Inst.ItemManager.GetItemStats("thr_StrelskyThrusterMK1"));
        InvItemData itemData103 = new InvItemData();

        itemData103.Item     = item103;
        itemData103.Quantity = 1;


        Item        item104     = new Item(GameManager.Inst.ItemManager.GetItemStats("shd_NCPTransporterShieldMK1"));
        InvItemData itemData104 = new InvItemData();

        itemData104.Item     = item104;
        itemData104.Quantity = 1;


        Item        item105     = new Item(GameManager.Inst.ItemManager.GetItemStats("dfs_CMDispenser"));
        InvItemData itemData105 = new InvItemData();

        itemData105.Item          = item105;
        itemData105.Quantity      = 1;
        itemData105.RelatedItemID = "ammo_LongDurationCM";


        Item        item110     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_SDCStomperAutocannon"));
        InvItemData itemData110 = new InvItemData();

        itemData110.Item          = item110;
        itemData110.Quantity      = 1;
        itemData110.RelatedItemID = "ammo_20mmTitaniumSlugs";


        Item        item111     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_StrelskyScreamerMissileLauncher"));
        InvItemData itemData111 = new InvItemData();

        itemData111.Item          = item111;
        itemData111.Quantity      = 1;
        itemData111.RelatedItemID = "ammo_StrelskySeekerMissile";


        Item        item112     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_AlFasadIonFluxTurretMK1"));
        InvItemData itemData112 = new InvItemData();

        itemData112.Item     = item112;
        itemData112.Quantity = 1;


        Item        item113     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_CGGAnnihilatorTurretMK2"));
        InvItemData itemData113 = new InvItemData();

        itemData113.Item     = item113;
        itemData113.Quantity = 1;


        Item        item114     = new Item(GameManager.Inst.ItemManager.GetItemStats("shd_KeslerFighterShieldMK1"));
        InvItemData itemData114 = new InvItemData();

        itemData114.Item     = item114;
        itemData114.Quantity = 1;

        Item        item115     = new Item(GameManager.Inst.ItemManager.GetItemStats("wpn_AlFasadStingerPulseCannon"));
        InvItemData itemData115 = new InvItemData();

        itemData115.Item     = item115;
        itemData115.Quantity = 1;


        Item        item120     = new Item(GameManager.Inst.ItemManager.GetItemStats("ammo_LongDurationCM"));
        InvItemData itemData120 = new InvItemData();

        itemData120.Item     = item120;
        itemData120.Quantity = UnityEngine.Random.Range(1, 3);


        Item        item121     = new Item(GameManager.Inst.ItemManager.GetItemStats("ammo_20mmTitaniumSlugs"));
        InvItemData itemData121 = new InvItemData();

        itemData121.Item     = item121;
        itemData121.Quantity = 500;

        //generate loadout
        party.LeaderLoadout = new Loadout("Trimaran", ShipType.Transport);

        party.LeaderLoadout.HullAmount        = GameManager.Inst.ItemManager.GetShipStats(party.LeaderLoadout.ShipID).Hull;
        party.LeaderLoadout.FuelAmount        = GameManager.Inst.ItemManager.GetShipStats(party.LeaderLoadout.ShipID).MaxFuel;
        party.LeaderLoadout.LifeSupportAmount = GameManager.Inst.ItemManager.GetShipStats(party.LeaderLoadout.ShipID).LifeSupport;

        party.LeaderLoadout.Defensives = new List <InvItemData>();

        party.LeaderLoadout.ShipMods = new InvItemData[GameManager.Inst.ItemManager.GetShipStats(party.LeaderLoadout.ShipID).ModSlots];



        party.LeaderLoadout.WeaponCapacitor = itemData1;
        party.LeaderLoadout.Shield          = itemData4;
        party.LeaderLoadout.Defensives.Add(itemData5);
        party.LeaderLoadout.Thruster = itemData3;
        party.LeaderLoadout.Scanner  = itemData2;
        party.LeaderLoadout.AmmoBayItems.Add(itemData20);
        party.LeaderLoadout.AmmoBayItems.Add(itemData21);

        party.LeaderLoadout.WeaponJoints = new Dictionary <string, InvItemData>()
        {
            { "GimballLeft", itemData10 },
            { "GimballRight", itemData10 },
            { "TurretLeft", itemData12 },
            { "TurretRight", itemData12 },
            { "TurretTop", itemData13 },
        };



        party.FollowerLoadouts = new List <Loadout>();
        for (int i = 0; i < UnityEngine.Random.Range(1, 5); i++)
        {
            Loadout loadout = new Loadout("Spitfire", ShipType.Fighter);
            party.FollowerLoadouts.Add(loadout);
            loadout.WeaponJoints = new Dictionary <string, InvItemData>()
            {
                { "GimballLeft", itemData115 },
                { "GimballRight", itemData115 },
                { "GimballFront", itemData111 },
            };

            loadout.HullAmount        = GameManager.Inst.ItemManager.GetShipStats(loadout.ShipID).Hull;
            loadout.FuelAmount        = GameManager.Inst.ItemManager.GetShipStats(loadout.ShipID).MaxFuel;
            loadout.LifeSupportAmount = GameManager.Inst.ItemManager.GetShipStats(loadout.ShipID).LifeSupport;

            loadout.Defensives = new List <InvItemData>();

            loadout.WeaponCapacitor = itemData1;
            if (UnityEngine.Random.value > 0.6f)
            {
                loadout.Defensives.Add(itemData5);
            }
            loadout.Shield   = itemData114;
            loadout.Thruster = itemData103;
            loadout.Scanner  = itemData102;
            loadout.AmmoBayItems.Add(itemData120);
            loadout.AmmoBayItems.Add(itemData121);

            loadout.ShipMods = new InvItemData[GameManager.Inst.ItemManager.GetShipStats(loadout.ShipID).ModSlots];
        }


        MacroAITask task = AssignMacroAITask(MacroAITaskType.None, party);

        party.IsInTradelane = false;
        //party.DestinationCoord = GameManager.Inst.WorldManager.AllNavNodes["cambridge_station"].Location;
        party.MoveSpeed    = 10f;
        party.NextTwoNodes = new List <NavNode>();
        party.PrevNode     = null;    //CreateTempNode(party.Location, "tempstart", GameManager.Inst.WorldManager.AllSystems[party.CurrentSystemID]);

        LoadPartyTreeset(party);

        GameManager.Inst.NPCManager.AllParties.Add(party);
    }
Exemple #21
0
    public MacroAITask AssignMacroAITask(MacroAITaskType prevTaskType, MacroAIParty party)
    {
        MacroAITask task = new MacroAITask();

        if (prevTaskType == MacroAITaskType.None)
        {
            if (UnityEngine.Random.value > 0.0f)
            {
                prevTaskType = MacroAITaskType.Stay;
            }
            else
            {
                prevTaskType = MacroAITaskType.Travel;
            }
        }

        party.PrevNode = null;
        if (party.NextTwoNodes != null)
        {
            party.NextTwoNodes.Clear();
        }
        if (prevTaskType == MacroAITaskType.Travel)
        {
            if (!string.IsNullOrEmpty(party.DockedStationID) && UnityEngine.Random.value < 0.75f)
            {
                task.TaskType     = MacroAITaskType.Trade;
                task.StayDuration = UnityEngine.Random.Range(10f, 30f);
                party.WaitTimer   = 0;
                party.RunningNodeHist.UniquePush("Trading for " + task.StayDuration);
                Debug.LogError("Party " + party.PartyNumber + " Task has been assigned to party: Trade, current station" + party.DockedStationID);

                TradeCommodity(party, GameManager.Inst.WorldManager.DockableStationDatas[party.DockedStationID]);
            }
            else
            {
                task.TaskType     = MacroAITaskType.Stay;
                task.StayDuration = UnityEngine.Random.Range(15f, 35f);
                party.WaitTimer   = 0;
                party.RunningNodeHist.UniquePush("Stay for " + task.StayDuration);
                Debug.LogError("Party " + party.PartyNumber + " Task has been assigned to party: " + task.TaskType + " for " + task.StayDuration);
            }
        }
        else if (prevTaskType == MacroAITaskType.Stay || prevTaskType == MacroAITaskType.Trade)
        {
            task.TaskType = MacroAITaskType.Travel;
            List <string> keyList = new List <string>(GameManager.Inst.WorldManager.AllSystems.Keys);
            if (Time.time < 0)
            {
                Debug.LogError("new task for initial test");
                StarSystemData destSystem = GameManager.Inst.WorldManager.AllSystems[keyList[UnityEngine.Random.Range(0, keyList.Count)]];
                //StarSystemData destSystem = GameManager.Inst.WorldManager.AllSystems["washington_system"];
                //StarSystemData destSystem = GameManager.Inst.WorldManager.AllSystems["new_england_system"];
                task.TravelDestSystemID = destSystem.ID;

                task.TravelDestNodeID = destSystem.Stations[UnityEngine.Random.Range(0, destSystem.Stations.Count)].ID;
                //task.TravelDestNodeID = "annandale_station";//"planet_colombia_landing";//"bethesda_station";
                task.IsDestAStation = true;
                //task.TravelDestCoord = new RelLoc(destSystem.OriginPosition, new Vector3(-28.3f, 5f, 418.8f), null);
            }
            else
            {
                Debug.LogError("new task to random station in random system");
                StarSystemData destSystem = GameManager.Inst.WorldManager.AllSystems[keyList[UnityEngine.Random.Range(0, keyList.Count)]];
                //StarSystemData destSystem = GameManager.Inst.WorldManager.AllSystems["washington_system"];

                task.TravelDestSystemID = destSystem.ID;
                task.TravelDestNodeID   = destSystem.Stations[UnityEngine.Random.Range(0, destSystem.Stations.Count)].ID;
                //task.TravelDestNodeID = "planet_colombia_landing";
                task.IsDestAStation = true;
            }

            party.WaitTimer = 0;
            Debug.LogError("Party " + party.PartyNumber + " Task has been assigned to party: " + task.TaskType + " to " + (task.IsDestAStation ? task.TravelDestNodeID : task.TravelDestCoord.ToString()));
        }

        party.CurrentTask        = task;
        party.HasReachedDestNode = false;

        if (party.CurrentTask.TaskType == MacroAITaskType.Travel)
        {
            if (party.CurrentTask.IsDestAStation)
            {
                party.DestNode = GameManager.Inst.WorldManager.AllNavNodes[party.CurrentTask.TravelDestNodeID];
            }
            else
            {
                //party.DestNode = CreateTempNode(party.CurrentTask.TravelDestCoord, "tempdest", GameManager.Inst.WorldManager.AllSystems[party.CurrentTask.TravelDestSystemID]);
                party.DestNode = GetClosestNodeToLocation(party.CurrentTask.TravelDestCoord.RealPos, GameManager.Inst.WorldManager.AllSystems[party.CurrentTask.TravelDestSystemID]);
            }
        }



        return(task);
    }