Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        if (File.Exists(Application.persistentDataPath + "/" + playerDataPath))
        {
            string json = File.ReadAllText(Application.persistentDataPath + "/" + playerDataPath);
            playerData = JsonUtility.FromJson <PlayerData>(json);
        }
        else
        {
            playerData               = new PlayerData();
            playerData.points        = 0;
            playerData.zombieskilled = 0;
            playerData.unitsDeployed = 0;
            playerData.lastlevel     = 0;
            string json = JsonUtility.ToJson(playerData);
            File.WriteAllText(Application.persistentDataPath + "/" + playerDataPath, json);
        }

        if (File.Exists(Application.persistentDataPath + "/" + unitsDataPath))
        {
            string json = File.ReadAllText(Application.persistentDataPath + "/" + unitsDataPath);
            unitsData = JsonUtility.FromJson <UnitsData>(json);
        }
        else
        {
            unitsData                   = new UnitsData();
            unitsData.units             = new Unit[2];
            unitsData.units[0]          = new Unit();
            unitsData.units[0].typeName = "Pistolero";
            unitsData.units[0].level    = 1;
            unitsData.units[1]          = new Unit();
            unitsData.units[1].typeName = "Francotirador";
            unitsData.units[1].level    = 1;
        }
    }
Ejemplo n.º 2
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        byte _unitID = Game.Instance.GetUnitIDInArmy(_slotID, out bool error);

        if (error == false)
        {
            _infoWindow.SetActive(true);
            _infoText.text = UnitsData.GetUnit(_unitID).ToString();
        }
    }
Ejemplo n.º 3
0
        public MainPageViewModel()
        {
            _unitsData = UnitsData.Deserialize();

            foreach (var unitType in _unitsData.UnitTypes)
            {
                Items.Add(new UnitsTabViewModel(unitType));
            }

            ActivateItem(Items[0]);
        }
Ejemplo n.º 4
0
 private void Awake()
 {
     instance = this;
     DontDestroyOnLoad(this);
     SceneManager.sceneLoaded += OnLevelLoaded;
 }
Ejemplo n.º 5
0
 private void UpdateUI(int slotID, byte unitID)
 {
     _troopSprite[slotID].sprite = Resources.Load <Sprite>(UnitsData.GetUnit(unitID).Sprite);
     _troopCount[slotID].text    = _troops[slotID].Count.ToString();
 }