Beispiel #1
0
        public static ShipDataPacket loadData_shipData(string fileName)
        {
            FileStream     file         = null;
            ShipDataPacket returnPacket = null;

            try {
                BinaryFormatter formatter = new BinaryFormatter();

                file = File.Open(Application.persistentDataPath + fileName, FileMode.Open);

                returnPacket = formatter.Deserialize(file) as ShipDataPacket;
            } catch (Exception e)
            {
                Debug.Log("There was an exception...? Loading Cust");
                returnPacket = new ShipDataPacket();
            } finally {
                if (file != null)
                {
                    file.Close();
                }
            }

            //Debug.Log("Path is: " + (Application.persistentDataPath + fileName));

            return(returnPacket);
        }
    // ------------------------------------------------------------------------------------------------------
    // ----------- Array management stuff: --------------------------------------------------------
    // ------------------------------------------------------------------------------------------------------

    public void loadShipButtons(ShipDataPacket shipDataPacket)
    {
        ShipDataIndividual[] shipData = shipDataPacket.getShipData();
        int numOfSavedShips           = shipDataPacket.getNumOfSavedShips();

        shipButtonArray = new ShipButtonScript[numOfSavedShips];

        for (int index = 0; index < numOfSavedShips; index++)
        {
            createNewShipButton(index, shipData[index].getShipName(), shipData[index].getCannonSelection());
        }

        moveShipButtonNewToTheEndOfTheList();

        currentlySelectedButton = shipDataPacket.getPreviouslySelectedShip();

        if (currentlySelectedButton >= 0)
        {
            shipSelection.buttonPressed_ShipButton(currentlySelectedButton);
        }
        else
        {
            shipSelection.buttonPressed_SelectRandom();
            firstButtonSelected = true;
        }
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        // Make the game run at 60fps:
        Application.targetFrameRate    = 60;
        Input.simulateMouseWithTouches = false;


        shipRotationManager = playerShip_parent.GetComponent <ShipRotationManager_ShipSelection>();
        shipWakeController  = playerShip_parent.GetComponent <WakeController_ShipSelection>();

        shipDataPacket = loadShipData();
        shipButtonManager.loadShipButtons(shipDataPacket);
        shipTextureManager.initializeShipMaterials(tempShipColor, tempSailPatternSelection, tempSailIsMirrored_horizontal, tempSailIsMirrored_vertical);

        generateSurroundingTerrain();
    }
Beispiel #4
0
        public static void saveData_shipData(ShipDataPacket packet, string fileName)
        {
            FileStream file = null;

            try {
                BinaryFormatter formatter = new BinaryFormatter();

                file = File.Create(Application.persistentDataPath + fileName);

                formatter.Serialize(file, packet);
            } catch (Exception e) {
                Debug.Log("There was an exception...? Saving ShipData");
            } finally {
                if (file != null)
                {
                    file.Close();
                }
            }
        }