Exemplo n.º 1
0
    void Initialize()
    {
        mnpcdo = new MerchantNPCDataObject();

        hullNames = dbHulls.database.Select(x => x.name).ToArray();
        hullIDs   = dbHulls.database.Select(x => x.iD).ToArray();

        engineNames = new string[] { "None" };
        engineIDs   = new int[] { 0 };

        cargoNames = new string[] { "None" };
        cargoIDs   = new int[] { 0 };

        shieldNames = new string[] { "None" };
        shieldIDs   = new int[] { 0 };

        platingNames = new string[] { "None" };
        platingIDs   = new int[] { 0 };

        sectorNames = dbSectors.database.Select(x => x.sectorName).ToArray();
        sectorIDs   = dbSectors.database.Select(x => x.sectorID).ToArray();

        stationNames = new string[] { "None" };
        stationIDs   = new int[] { 0 };
    }
Exemplo n.º 2
0
 void ResetForm()
 {
     isEdit = false;
     currentlySelectedMerchantID = 0;
     saveButtonText   = "CREATE";
     isDockedInSector = false;
     mnpcdo           = new MerchantNPCDataObject();
 }
    public MerchantNPCDataObject GetMerchantByID(int MerchantID)
    {
        MerchantNPCDataObject mnpc = database.Find(x => x.MerchantID.Equals(MerchantID));

        if (mnpc.MerchantFirstName == string.Empty)
        {
            mnpc = new MerchantNPCDataObject();
        }
        return(mnpc);
    }
Exemplo n.º 4
0
    void DeleteRecord()
    {
        int idxRecord;

        //Find the object in the database
        MerchantNPCDataObject tempmnpcdo = dbMerchants.database.Find(x => x.MerchantID.Equals(currentlySelectedMerchantID));

        //Get the index
        idxRecord = dbMerchants.database.IndexOf(tempmnpcdo);

        //Remove by index
        dbMerchants.database.RemoveAt(idxRecord);

        //Update the SOs
        EditorUtility.SetDirty(dbStations);

        ResetForm();
    }
Exemplo n.º 5
0
    void CreateRecord()
    {
        currentlySelectedMerchantID = dbMerchants.database.Count > 0 ? dbMerchants.database.Max(x => x.MerchantID) + 1 : 1;
        mnpcdo                   = new MerchantNPCDataObject();
        mnpcdo.MerchantID        = currentlySelectedMerchantID;
        mnpcdo.MerchantFirstName = "New";
        mnpcdo.MerchantLastName  = "Merchant";
        mnpcdo.MerchantGender    = "Undetermined";
        mnpcdo.MerchantFaction   = 0;

        mnpcdo.HullID    = 0;
        mnpcdo.EngineID  = 0;
        mnpcdo.CargoID   = 0;
        mnpcdo.ShieldID  = 0;
        mnpcdo.PlatingID = 0;

        mnpcdo.IsDestroyed = false;
    }
    void CreateRecord()
    {
        currentlySelectedMerchantID = dbMerchants.database.Count > 0 ? dbMerchants.database.Max(x => x.MerchantID) + 1 : 1;
        mnpcdo = new MerchantNPCDataObject();
        mnpcdo.MerchantID = currentlySelectedMerchantID;
        mnpcdo.MerchantFirstName = "New";
        mnpcdo.MerchantLastName = "Merchant";
        mnpcdo.MerchantGender = "Undetermined";
        mnpcdo.MerchantFaction = 0;

        mnpcdo.HullID = 0;
        mnpcdo.EngineID = 0;
        mnpcdo.CargoID = 0;
        mnpcdo.ShieldID = 0;
        mnpcdo.PlatingID = 0;

        mnpcdo.IsDestroyed = false;
    }
Exemplo n.º 7
0
    void MerchantEditor()
    {
        if (currentlySelectedMerchantID > 0 && isEdit == true)
        {
            mnpcdo = dbMerchants.GetMerchantByID(currentlySelectedMerchantID);
        }


        //#################################################################################
        //Demographics -- Identifiers and such
        mnpcdo.MerchantFirstName = EditorGUILayout.TextField("First name", mnpcdo.MerchantFirstName, GUILayout.Width(300));
        mnpcdo.MerchantLastName  = EditorGUILayout.TextField("Last name", mnpcdo.MerchantLastName, GUILayout.Width(300));
        EditorGUILayout.LabelField("Faction will go here");

        EditorGUILayout.Space();

        //#################################################################################
        //Ship -- Hull must be selected for the components to be made available.
        //  Components will only display those with proper class for the hull
        mnpcdo.HullID = EditorGUILayout.IntPopup("Ship hull", mnpcdo.HullID, hullNames, hullIDs, GUILayout.Width(350));
        if (mnpcdo.HullID > 0)
        {
            FilterShipComponentsByHullClasses(mnpcdo.HullID);
        }

        EditorGUI.BeginDisabledGroup(mnpcdo.HullID == 0);
        mnpcdo.EngineID  = EditorGUILayout.IntPopup("Engine", mnpcdo.EngineID, engineNames, engineIDs, GUILayout.Width(350));
        mnpcdo.CargoID   = EditorGUILayout.IntPopup("Cargo hold", mnpcdo.CargoID, cargoNames, cargoIDs, GUILayout.Width(350));
        mnpcdo.ShieldID  = EditorGUILayout.IntPopup("Shields", mnpcdo.ShieldID, shieldNames, shieldIDs, GUILayout.Width(350));
        mnpcdo.PlatingID = EditorGUILayout.IntPopup("Plating", mnpcdo.PlatingID, platingNames, platingIDs, GUILayout.Width(350));
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        //#################################################################################
        //Starting values

        EditorGUI.BeginChangeCheck();
        mnpcdo.CurrentSectorID = EditorGUILayout.IntPopup("Starting sector", mnpcdo.CurrentSectorID, sectorNames, sectorIDs, GUILayout.Width(300));
        if (mnpcdo.CurrentSectorID > 0)
        {
            FilterStationsBySectorID(mnpcdo.CurrentSectorID);
        }

        if (mnpcdo.CurrentStationID > 0)
        {
            isDockedInSector = true;
        }
        isDockedInSector = EditorGUILayout.Toggle("Docked?", isDockedInSector);
        EditorGUI.BeginDisabledGroup(!isDockedInSector);
        mnpcdo.CurrentStationID = EditorGUILayout.IntPopup("Docked at", mnpcdo.CurrentStationID, stationNames, stationIDs, GUILayout.Width(300));
        if (!isDockedInSector)
        {
            mnpcdo.CurrentStationID = 0;
        }
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        mnpcdo.MerchantTickModifier = EditorGUILayout.FloatField("Sim tick modifier", mnpcdo.MerchantTickModifier, GUILayout.Width(200));

        //#################################################################################
        //Buttons -- Save will change to either CREATE or UPDATE depending on how we started
        //  CREATE just needs an empty form. UPDATE requires a sidebar selection.
        //  CLEAR will empty all memorized values

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button(saveButtonText, GUILayout.Width(125)))
        {
            GUIUtility.keyboardControl = 0;
            if (isEdit == true)
            {
                UpdateRecord();
            }
            else
            {
                SaveRecord();
            }

            ResetForm();
        }
        if (GUILayout.Button("Cancel", GUILayout.Width(125)))
        {
            ResetForm();
        }

        EditorGUILayout.EndHorizontal();

        //###############################################################################################
        // Delete this station and child shops

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        okDelete = EditorGUILayout.BeginToggleGroup("Delete the merchant?", okDelete);

        //Sanity check(mark)
        if (GUILayout.Button("Delete", GUILayout.Width(125)) && currentlySelectedMerchantID > 0)
        {
            DeleteRecord();

            okDelete = false;
        }

        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.EndHorizontal();
    }
 void ResetForm()
 {
     isEdit = false;
     currentlySelectedMerchantID = 0;
     saveButtonText = "CREATE";
     isDockedInSector = false;
     mnpcdo = new MerchantNPCDataObject();
 }
    void MerchantEditor()
    {
        if (currentlySelectedMerchantID > 0 && isEdit == true)
        {
            mnpcdo = dbMerchants.GetMerchantByID(currentlySelectedMerchantID);
        }

        //#################################################################################
        //Demographics -- Identifiers and such
        mnpcdo.MerchantFirstName = EditorGUILayout.TextField("First name", mnpcdo.MerchantFirstName, GUILayout.Width(300));
        mnpcdo.MerchantLastName = EditorGUILayout.TextField("Last name", mnpcdo.MerchantLastName, GUILayout.Width(300));
        EditorGUILayout.LabelField("Faction will go here");

        EditorGUILayout.Space();

        //#################################################################################
        //Ship -- Hull must be selected for the components to be made available.
        //  Components will only display those with proper class for the hull
        mnpcdo.HullID = EditorGUILayout.IntPopup("Ship hull", mnpcdo.HullID, hullNames, hullIDs, GUILayout.Width(350));
        if (mnpcdo.HullID > 0 ) { FilterShipComponentsByHullClasses(mnpcdo.HullID); }

        EditorGUI.BeginDisabledGroup(mnpcdo.HullID == 0);
        mnpcdo.EngineID = EditorGUILayout.IntPopup("Engine", mnpcdo.EngineID, engineNames, engineIDs, GUILayout.Width(350));
        mnpcdo.CargoID = EditorGUILayout.IntPopup("Cargo hold", mnpcdo.CargoID, cargoNames, cargoIDs, GUILayout.Width(350));
        mnpcdo.ShieldID = EditorGUILayout.IntPopup("Shields", mnpcdo.ShieldID, shieldNames, shieldIDs, GUILayout.Width(350));
        mnpcdo.PlatingID = EditorGUILayout.IntPopup("Plating", mnpcdo.PlatingID, platingNames, platingIDs, GUILayout.Width(350));
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        //#################################################################################
        //Starting values

        EditorGUI.BeginChangeCheck();
        mnpcdo.CurrentSectorID = EditorGUILayout.IntPopup("Starting sector", mnpcdo.CurrentSectorID, sectorNames, sectorIDs, GUILayout.Width(300));
        if (mnpcdo.CurrentSectorID > 0 ) { FilterStationsBySectorID(mnpcdo.CurrentSectorID); }

        if (mnpcdo.CurrentStationID > 0) { isDockedInSector = true; }
        isDockedInSector = EditorGUILayout.Toggle("Docked?", isDockedInSector);
        EditorGUI.BeginDisabledGroup(!isDockedInSector);
        mnpcdo.CurrentStationID = EditorGUILayout.IntPopup("Docked at", mnpcdo.CurrentStationID, stationNames, stationIDs, GUILayout.Width(300));
        if (!isDockedInSector) { mnpcdo.CurrentStationID = 0; }
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        mnpcdo.MerchantTickModifier = EditorGUILayout.FloatField("Sim tick modifier", mnpcdo.MerchantTickModifier, GUILayout.Width(200));

        //#################################################################################
        //Buttons -- Save will change to either CREATE or UPDATE depending on how we started
        //  CREATE just needs an empty form. UPDATE requires a sidebar selection.
        //  CLEAR will empty all memorized values

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button(saveButtonText, GUILayout.Width(125))) {
            GUIUtility.keyboardControl = 0;
            if (isEdit == true)
            {
                UpdateRecord();
            }
            else
            {
                SaveRecord();
            }

            ResetForm();
        }
        if (GUILayout.Button("Cancel", GUILayout.Width(125))) { ResetForm(); }

        EditorGUILayout.EndHorizontal();

        //###############################################################################################
        // Delete this station and child shops

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        okDelete = EditorGUILayout.BeginToggleGroup("Delete the merchant?", okDelete);

        //Sanity check(mark)
        if (GUILayout.Button("Delete", GUILayout.Width(125)) && currentlySelectedMerchantID > 0)
        {
            DeleteRecord();

            okDelete = false;
        }

        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.EndHorizontal();
    }
    void Initialize()
    {
        mnpcdo = new MerchantNPCDataObject();

        hullNames = dbHulls.database.Select(x => x.name).ToArray();
        hullIDs = dbHulls.database.Select(x => x.iD).ToArray();

        engineNames = new string[] { "None" };
        engineIDs = new int[] { 0 };

        cargoNames = new string[] { "None" };
        cargoIDs = new int[] { 0 };

        shieldNames = new string[] { "None" };
        shieldIDs = new int[] { 0 };

        platingNames = new string[] { "None" };
        platingIDs = new int[] { 0 };

        sectorNames = dbSectors.database.Select(x => x.sectorName).ToArray();
        sectorIDs = dbSectors.database.Select(x => x.sectorID).ToArray();

        stationNames = new string[] { "None" };
        stationIDs = new int[] { 0 };
    }
 public void Remove(MerchantNPCDataObject dataObject)
 {
     database.Remove(dataObject);
 }
 public void Add(MerchantNPCDataObject dataObject)
 {
     database.Add(dataObject);
 }
 public void Remove(MerchantNPCDataObject dataObject)
 {
     database.Remove(dataObject);
 }
 public MerchantNPCDataObject GetMerchantByID(int MerchantID)
 {
     MerchantNPCDataObject mnpc = database.Find(x => x.MerchantID.Equals(MerchantID));
     if (mnpc.MerchantFirstName == string.Empty) { mnpc = new MerchantNPCDataObject(); }
     return mnpc;
 }
 public void Add(MerchantNPCDataObject dataObject)
 {
     database.Add(dataObject);
 }