Example #1
0
    public static List <ShipBodyMaterial> loadShip(int shipSlotNumber)
    {
        List <ShipBodyMaterial> shipMatrix = new List <ShipBodyMaterial>();
        List <ShipSaveHolder>   ship       = new List <ShipSaveHolder>();

        if (File.Exists(Application.persistentDataPath + "/" + OptionsController.GetConstantValue(0) + "_ship" + shipSlotNumber + ".dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/" + OptionsController.GetConstantValue(0) + "_ship" + shipSlotNumber + ".dat", FileMode.Open);
            ship = (List <ShipSaveHolder>)bf.Deserialize(file);
            file.Close();
            if (ship.Count > 0)
            {
                foreach (ShipSaveHolder ssh in ship)
                {
                    ShipBodyMaterial sbm = new ShipBodyMaterial();
                    sbm.cell.x = ssh.posX;
                    sbm.cell.y = ssh.posY;
                    //sbm.stats = ssh.sms;
                    shipMatrix.Add(sbm);
                }
            }
        }
        else
        {
            Debug.Log("There is no ship in Ship Slot:" + shipSlotNumber + " for Profile:" + OptionsController.GetConstantValue(0));
        }
        return(shipMatrix);
    }
Example #2
0
    public List <ShipBodyMaterial> transformToMatrix()
    {
        List <ShipBodyMaterial> shipMatrix = new List <ShipBodyMaterial>();

        foreach (Transform t in transform)
        {
            if (t.GetComponent <BuilderGridNode>().isSelected)
            {
                ShipBodyMaterial sbm = new ShipBodyMaterial();
                shipMatrix.Add(t.GetComponent <BuilderGridNode>().material);
            }
        }
        return(shipMatrix);
    }