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
 void Start()
 {
     for (int x = 0; x < gridSize; x++)
     {
         for (int y = 0; y < gridSize; y++)
         {
             GameObject go = (GameObject)Instantiate(pixelPrefab, new Vector3(x / 2.5f, y / 2.5f * (-1f), 0f), Quaternion.identity);
             go.GetComponent <BuilderGridNode>().material = selectedBodyMaterial.getMaterial();
             go.transform.parent = this.transform;
             if (x == ((gridSize - 1) / 2) && y == ((gridSize - 1) / 2))
             {
                 mainNode = go.GetComponent <BuilderGridNode>();
             }
         }
     }
     StartCoroutine("ChooseMainGrid");
     userName = OptionsController.GetConstantValue(0);
     GameObject.Find("BuilderCanvas").transform.FindChild("ProfileName").GetComponent <UnityEngine.UI.Text>().text = "Profile: " + userName;
 }
Example #3
0
 void Awake()
 {
     transform.parent.GetChild(0).FindChild("Profile").GetComponent <Text>().text = "Profile: " + OptionsController.GetConstantValue(0);
     transform.FindChild("ProfileNameInputField").FindChild("Text").GetComponent <Text>().text = OptionsController.GetConstantValue(0);
 }
Example #4
0
    public void OnSaveButtonClick()
    {
        string profileName = transform.FindChild("ProfileNameInputField").FindChild("Text").GetComponent <Text>().text;

        if (!string.IsNullOrEmpty(profileName))
        {
            OptionsController.ChangeConstant(0, profileName);
            transform.parent.GetChild(0).FindChild("Profile").GetComponent <Text>().text = "Profile: " + OptionsController.GetConstantValue(0);
        }
        //...
        OptionsController.SaveGameOptions();
    }
Example #5
0
    IEnumerator getProfileName()
    {
        yield return(new WaitForEndOfFrame());

        transform.FindChild("Profile").GetComponent <Text>().text = "Profile: " + OptionsController.GetConstantValue(0);
    }