Exemple #1
0
    void OnGUI()
    {
        if (GUILayout.Button("Clear Save"))
        {
            PlayerPrefs.DeleteAll();
        }

        GUILayout.Space(20);
        GUILayout.Label("Wagon ID:");
        wagonID = GUILayout.TextField(wagonID);
        if (GUILayout.Button("Add Wagon"))
        {
            var wagon = GameManager.Instance.WagonData.FirstOrDefault(w => w.ID == wagonID);
            if (wagon != null)
            {
                FindObjectOfType <Vehicle>().AddWagon(SerialisationUtility.DeserialiseWagon(wagon));
            }
            else
            {
                Debug.LogError("Cant find wagon for name: " + wagonID);
            }
        }

        if (GUILayout.Button("GenerateEnums"))
        {
            EnumGenerator.GenerateEnumFile();
        }
    }
Exemple #2
0
    private void OnWagonBought(object sender, ValueArgs <object> args)
    {
        var wagonData = args.Value as WagonData;

        if (GameManager.Instance.RemoveScore(wagonData.Cost))

        {
            GameManager.Instance.vehicleMovement.GetVehicle().AddWagon(SerialisationUtility.DeserialiseWagon(wagonData));
        }
    }
Exemple #3
0
 private void RecoverSavedVehicleData()
 {
     if (PlayerPrefs.HasKey(saveName))
     {
         foreach (var wagonDataString in PlayerPrefs.GetString(saveName).Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
         {
             var wagon = SerialisationUtility.DeserialiseWagon(wagonDataString);
             if (wagon != null)
             {
                 AddWagon(wagon);
             }
             else
             {
                 Debug.Log("Cant find wagon for: " + wagonDataString);
             }
         }
     }
     else
     {
         var locomotiveData = GameManager.Instance.WagonData.FirstOrDefault(x => x.ID == "Locomotive");
         AddWagon(SerialisationUtility.DeserialiseWagon(locomotiveData));
     }
 }