Ejemplo n.º 1
0
    //TODO: ВРЕМЕННЫЙ КОД
    private void CreateTestingJorney()
    {
        if (PlayerPrefs.GetInt("firstRunning") == 0)
        {
            Hero _hero = new Hero
            {
                id = 2,
            };
            _hero.setName("Adrian Fon Zigler");
            _hero.setHealth(10000);
            _hero.setPower(1);
            string heroSerialized = JsonUtility.ToJson(_hero);
            if (!Directory.Exists(Application.persistentDataPath + "/" + HeroDataManager.SaveHeroesFolder))
            {
                Directory.CreateDirectory(Application.persistentDataPath + "/" + HeroDataManager.SaveHeroesFolder);
            }
            DataController.tryWriteSaveInFile(_hero.id.ToString() + ".hr", Application.persistentDataPath + "/" + HeroDataManager.SaveHeroesFolder, heroSerialized);

            JorneyData jorney = new JorneyData
            {
                heroID   = 2,
                hero     = _hero,
                distance = 0,
            };
            string jorneySerialized = JsonUtility.ToJson(jorney);
            if (!Directory.Exists(Application.persistentDataPath + "/" + JorneyDataManager.jorneysFolderName))
            {
                Directory.CreateDirectory(Application.persistentDataPath + "/" + JorneyDataManager.jorneysFolderName);
            }

            DataController.tryWriteSaveInFile(jorney.id + ".jor", Application.persistentDataPath + "/" + JorneyDataManager.jorneysFolderName, jorneySerialized);
            Debug.Log("JORNEY CONTROLLER: testing jorney created!");
            PlayerPrefs.SetInt("firstRunning", 1);
        }
    }
Ejemplo n.º 2
0
    public override bool end(JorneyData _jorney)
    {
        if (enemy == null)
        {
            enemy = Instantiate(ReferenceEnemy);
        }
        //если боевое событие закончено - не продолжать бой
        if (!_jorney.hero.isAlive() || !enemy.isAlive())
        {
            return(true);
        }


        //если после очередной атаки враг погиб
        Debug.Log("Hero health: " + _jorney.hero.getHealth() + " Enemy health: " + enemy.getHealth());
        if (enemy.dealDamage(_jorney.hero.getPower()))
        {
            //пишем описание смерти в лог
            DiaryManager.adventureLog(_jorney, endDescription);
            //даем знать, что событие окончено
            return(true);
        }

        //TODO: добавить механику смерти героя
        if (_jorney.hero.dealDamage(enemy.getPower()))
        {
            DiaryManager.adventureLog(_jorney, "Герой пал в сражении с " + enemy.getName());
            return(true);
        }

        return(false);
    }
Ejemplo n.º 3
0
    private static JorneyData loadJorneyData(string fileName)
    {
        JorneyData _jorneyData = new JorneyData();
        string     _JsonSave   = DataController.tryReadSaveFromFile(fileName, jorneysFolderPath);

        _jorneyData = JsonUtility.FromJson <JorneyData>(_JsonSave);
        Debug.Log("JORNEYS DATA MANAGER: data of jorney (id):" + _jorneyData.id + " loaded!");
        return(_jorneyData);
    }
Ejemplo n.º 4
0
    public static bool saveJorneyData(string jorneyID)
    {
        JorneyData jorneyData = getJorneyDataByID(jorneyID);

        if (jorneyData == null)
        {
            Debug.Log("JORNEY DATA MANAGER: jorney not found. Use addNewJorney() to add new object.");
        }
        string jsonSave = JsonUtility.ToJson(jorneyData);

        Debug.Log("JORNEY DATA MANAGER: jorney with id " + jorneyID + " saved.");
        return(DataController.tryWriteSaveInFile(jorneyID + ".jor", jorneysFolderPath, jsonSave));
    }
Ejemplo n.º 5
0
 public override bool isPossible(JorneyData _jorney)
 {
     return(true);
 }
Ejemplo n.º 6
0
 public override void begin(JorneyData _jorney)
 {
     enemy = Instantiate(ReferenceEnemy);
     DiaryManager.adventureLog(_jorney, description);
 }
Ejemplo n.º 7
0
 public virtual bool end(JorneyData jorney)
 {
     return(true);
 }
Ejemplo n.º 8
0
 public virtual void begin(JorneyData jorney)
 {
     DiaryManager.adventureLog(jorney, description);
 }
Ejemplo n.º 9
0
 public virtual bool isPossible(JorneyData jorney)
 {
     return(true);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Add new Jorney Data object to the system and save it.
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>
 public static bool addNewJorneyData(JorneyData _jorneyToAdd)
 {
     jorneysDataList.Add(_jorneyToAdd);
     return(saveJorneyData(_jorneyToAdd.id));
 }
Ejemplo n.º 11
0
 //добавляем новый элемент в дневник
 public static void adventureLog(JorneyData jorneyData, string message)
 {
     jorneyData.diary.addElement(new DiaryItem(jorneyData.timer.innerTime, message));
 }