protected void SaveLoadout(ShipLoadoutData shipLoadout, ShipMenu shipMenu, string fileName)
    {
        shipMenu.GetSelections();
        SaveToLoadoutData(shipLoadout, shipMenu);

        File.WriteAllText(Database.savePath + fileName, shipLoadout.GetJson());
    }
    //loads the ship's saved loadout
    protected void LoadLoadouts(ShipLoadoutData shipLoadout, ShipMenu shipMenu, string fileName)
    {
        if (File.Exists(Database.savePath + fileName))
        {
            string tempJson = File.ReadAllText(Database.savePath + fileName);
            JsonUtility.FromJsonOverwrite(tempJson, shipLoadout);
        }

        shipMenu.SetSelections(shipLoadout);
    }
Ejemplo n.º 3
0
    //sets ship's stats from loadoutData (includes its gun's stats too)
    public void Init(ShipLoadoutData loadoutData, string targetTag)
    {
        ShipData ship = loadoutData.Ship;

        this.targetTag = targetTag;

        gameObject.GetComponent <SpriteRenderer>().sprite = ship.Sprite;
        healthBar.color     = healthBarColour;
        gameObject.name     = ship.name;
        maxHealth           = ship.Health;
        speed               = ship.Speed;
        reload              = ship.Reload;
        firepower           = ship.Firepower;
        torpedo             = ship.Torpedo;
        armour              = ship.Armour;
        aviation            = ship.Aviation;
        accuracy            = ship.Accuracy;
        evasion             = ship.Evasion;
        luck                = ship.Luck;
        antiAir             = ship.AntiAir;
        slotMounts[0]       = ship.Slot1Mounts;
        slotMounts[1]       = ship.Slot2Mounts;
        slotMounts[2]       = ship.Slot3Mounts;
        slotEfficiencies[0] = ship.Slot1Efficiency;
        slotEfficiencies[1] = ship.Slot2Efficiency;
        slotEfficiencies[2] = ship.Slot3Efficiency;

        if (loadoutData.Slot1)
        {
            firepower += loadoutData.Slot1.Firepower;
            torpedo   += loadoutData.Slot1.Torpedo;
            antiAir   += loadoutData.Slot1.AntiAir;
        }
        if (loadoutData.Slot2)
        {
            firepower += loadoutData.Slot2.Firepower;
            torpedo   += loadoutData.Slot2.Torpedo;
            antiAir   += loadoutData.Slot2.AntiAir;
        }
        if (loadoutData.Slot3)
        {
            firepower += loadoutData.Slot3.Firepower;
            torpedo   += loadoutData.Slot3.Torpedo;
            antiAir   += loadoutData.Slot3.AntiAir;
        }

        health = maxHealth;
    }
Ejemplo n.º 4
0
 //sets values of each dropdown to previously saved selection, if applicable
 public void SetSelections(ShipLoadoutData loadoutData)
 {
     if (loadoutData.Ship)
     {
         SetDropdownSelection(shipDrop, loadoutData.Ship.Name);
     }
     if (loadoutData.Slot1)
     {
         SetDropdownSelection(slot1Drop, loadoutData.Slot1.Name);
     }
     if (loadoutData.Slot2)
     {
         SetDropdownSelection(slot2Drop, loadoutData.Slot2.Name);
     }
     if (loadoutData.Slot3)
     {
         SetDropdownSelection(slot3Drop, loadoutData.Slot3.Name);
     }
 }
 //stores the selected ships and guns from shipMenu into the shipLoadout
 protected void SaveToLoadoutData(ShipLoadoutData shipLoadout, ShipMenu shipMenu)
 {
     if (shipMenu.GetShip() != "None")
     {
         shipLoadout.Ship = Database.ShipList[shipMenu.GetShip()];
         if (shipMenu.GetSlot1() != "None")
         {
             shipLoadout.Slot1 = Database.GunList[shipMenu.GetSlot1()];
         }
         else
         {
             shipLoadout.Slot1 = null;
         }
         if (shipMenu.GetSlot2() != "None")
         {
             shipLoadout.Slot2 = Database.GunList[shipMenu.GetSlot2()];
         }
         else
         {
             shipLoadout.Slot2 = null;
         }
         if (shipMenu.GetSlot3() != "None")
         {
             shipLoadout.Slot3 = Database.GunList[shipMenu.GetSlot3()];
         }
         else
         {
             shipLoadout.Slot3 = null;
         }
     }
     else
     {
         shipLoadout.Ship  = null;
         shipLoadout.Slot1 = null;
         shipLoadout.Slot2 = null;
         shipLoadout.Slot3 = null;
     }
 }