Пример #1
0
    void Start()
    {
        page           = 0;
        numPages       = 6;
        currPage       = GameObject.Find("pg" + page.ToString());
        counter        = numPages;
        audiosource    = GameObject.Find("Right").GetComponent <AudioSource>();
        animator       = GameObject.Find("pg" + page.ToString()).GetComponent <Animator>();
        crystals_count = GameObject.Find("Knowledge_Crystals").GetComponent <Text>();
        PageSetActive();
        LeftPages[0].SetActive(true);
        UpdateCrystals();


        // Loading saved data
        // Load actual spellbook data file
        SpellbookData sd = SaveSystem.LoadSpellbookData();

        if (sd != null)
        {
            sorcerySetID   = sd.sorceryID;
            spellsUnlocked = sd.spellsUnlocked;
            foreach (GameObject g in spellTransLocation)
            {
                g.GetComponent <SorcerySpells>().CheckCondition();
            }
        }
        else
        {
            // Save new spellbook data file
            sorcerySetID   = 0;
            spellsUnlocked = new bool[7];
            SaveSystem.SaveNewSpellbookData();
        }
    }
Пример #2
0
    private SpellbookData GenerateBook(int level)
    {
        SpellbookData book = Instantiate(this.book);

        book.spells    = new List <Scroll>();
        book.pageCount = 8 + Random.Range(0, Mathf.CeilToInt(level / 2f));

        int   preSpells;
        float r = Random.Range(0.0f, 1.0f);

        if (r < 0.5)
        {
            preSpells = 1;
        }
        else if (r < 0.8)
        {
            preSpells = 2;
        }
        else
        {
            preSpells = 0;
        }

        while (book.spells.Count < preSpells)
        {
            book.spells.Add(GenerateScroll(level));
            book.pageCount += 1;
        }

        return(book);
    }
Пример #3
0
        private void receiveSpellBookContents(PacketReader reader)
        {
            ushort unknown        = reader.ReadUInt16(); // always 1
            Serial serial         = (Serial)reader.ReadInt32();
            ushort itemID         = reader.ReadUInt16();
            ushort spellbookType  = reader.ReadUInt16(); // 1==regular, 101=necro, 201=paladin, 401=bushido, 501=ninjitsu, 601=spellweaving
            ulong  spellBitfields = reader.ReadUInt64(); // first bit of first byte = spell #1, second bit of first byte = spell #2, first bit of second byte = spell #8, etc

            Spellbook = new SpellbookData(serial, itemID, spellbookType, spellBitfields);
        }
Пример #4
0
 public Spellbook(SpellbookData data)
 {
     totalPages = data.pageCount;
     bookName   = data.bookName;
     spells     = new List <Skill>();
     sprite     = data.sprite;
     foreach (Scroll scroll in data.spells)
     {
         spells.Add(scroll.skill);
     }
 }
Пример #5
0
    public static void SaveSpellbookData()
    {
        CheckDirectory();
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + DirectoryPath + SpellbookFileName;
        FileStream      stream    = new FileStream(path, FileMode.Create);

        SpellbookData data = new SpellbookData();

        formatter.Serialize(stream, data);
        stream.Close();
    }
Пример #6
0
    public static SpellbookData LoadSpellbookData()
    {
        string path = Application.persistentDataPath + DirectoryPath + SpellbookFileName;

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            SpellbookData data = formatter.Deserialize(stream) as SpellbookData;
            stream.Close();

            return(data);
        }
        else
        {
            Debug.LogError("No spellbook save file found.");
            return(null);
        }
    }