Ejemplo n.º 1
0
    public BaseChar loadChar()
    {
        //GameObject pc = GameObject.Find("Player Character");
        BaseChar bcClass = new BaseChar();//pc.GetComponent<BaseChar>();

        bcClass.charName = PlayerPrefs.GetString("Char name");
        bcClass.weight   = PlayerPrefs.GetInt("Weight");
        bcClass.height   = PlayerPrefs.GetInt("Height");

        //Archetype loading is missing

        for (int i = 0; i < Enum.GetValues(typeof(AttrNames)).Length; i++)
        {
            bcClass.getAttr(i).baseValue = PlayerPrefs.
                                           GetInt((AttrNames)i + " Base Value");
        }

        string[]  skills    = PlayerPrefs.GetString("Skills").Split('|');
        SkillTree skillTree = bcClass.CharClass.SkillTree;

        foreach (string skill in skills)
        {
            skillTree.Skills[skill].Known = true;
        }

        return(bcClass);
    }
Ejemplo n.º 2
0
    public void saveChar(BaseChar character)
    {
        //GameObject pc = GameObject.Find("Player Character");
        BaseChar bcClass = character;//pc.GetComponent<BaseChar>();

        PlayerPrefs.SetString("Char name", bcClass.charName);
        PlayerPrefs.SetInt("Weight", bcClass.weight);
        PlayerPrefs.SetInt("Height", bcClass.height);

        PlayerPrefs.SetString("Class", bcClass.CharClass.Name);

        for (int i = 0; i < Enum.GetValues(typeof(AttrNames)).Length; i++)
        {
            PlayerPrefs.SetInt((AttrNames)i + " Base Value",
                               bcClass.getAttr(i).baseValue);
        }
        string skills = "";

        Class charClass = bcClass.CharClass;

        foreach (Skill skill in charClass.SkillTree.Skills.Values)
        {
            if (skill.Known)
            {
                skills += skill.Name + "|";
            }
        }

        PlayerPrefs.SetString("Skills", skills);
    }
Ejemplo n.º 3
0
    public void calcValue()
    {
        float statValue = baseValue + gainedValue;

        foreach (ModAttribute modAttr in modifyingAttributes)
        {
            statValue += myChar.getAttr((int)modAttr.attrName).Value *
                         modAttr.modifier;
        }
        value = (int)statValue;
    }
Ejemplo n.º 4
0
    public BaseChar loadChar()
    {
        //GameObject pc = GameObject.Find("Player Character");
        BaseChar bcClass = new BaseChar();//pc.GetComponent<BaseChar>();

        bcClass.charName = PlayerPrefs.GetString("Char name");
        bcClass.weight = PlayerPrefs.GetInt("Weight");
        bcClass.height = PlayerPrefs.GetInt("Height");

        //Archetype loading is missing

        for (int i = 0; i < Enum.GetValues(typeof(AttrNames)).Length; i++)
            bcClass.getAttr(i).baseValue = PlayerPrefs.
                GetInt((AttrNames)i + " Base Value");

        string[] skills = PlayerPrefs.GetString("Skills").Split('|');
        SkillTree skillTree = bcClass.CharClass.SkillTree;

        foreach (string skill in skills)
            skillTree.Skills[skill].Known = true;

        return bcClass;
    }
Ejemplo n.º 5
0
    void showCharacterInfo(BaseChar selectedChar)
    {
        GUIContent content;

        GUI.DrawTexture(new Rect(567, 29, 76, 84), selectedChar.Image,
                        ScaleMode.ScaleToFit, true);
        GUI.Label(new Rect(648, 29, 150, 20), selectedChar.charName, "title");
        GUI.Label(new Rect(648, 49, 150, 20),
                  "Class: " + selectedChar.CharClass.Name, "title");
        GUI.Label(new Rect(648, 69, 150, 20), "Level: " + selectedChar.level,
                  "title");

        for (int i = 0; i < selectedChar.getAttributes().Length; i++)
        {
            BaseStat attribute = selectedChar.getAttr(i);
            content = new GUIContent(attribute.Name, attribute.description);
            GUI.Label(new Rect(571, 115 + i * 17, 100, 23), content);
            GUI.Label(new Rect(676, 115 + i * 17, 30, 23),
                      attribute.Value.ToString());
        }

        int nrOfPrimaryAttr = System.Enum.GetValues(typeof(AttrNames)).Length;
        int offset          = 128 + nrOfPrimaryAttr * 17;

        for (int i = 0; i < selectedChar.getSecondaryAttributes().Length; i++)
        {
            ModifiedStat secAttr  = selectedChar.getSecondaryAttr(i);
            string       attrName = secAttr.Name.Replace('_', ' ');
            content = new GUIContent(attrName, secAttr.description);
            GUI.Label(new Rect(571, offset + i * 18, 150, 23), content);
            if (i == (int)SecondaryAttrNames.Hit_Points)
            {
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                          selectedChar.CurrentHP.ToString() + "/" +
                          secAttr.Value.ToString(), "AttrValues");
                offset += 23;
                Texture2D PBEmpty, PBFull;
                PBEmpty = Helper.getImage("Inventory/ProgressBarEmpty");
                PBFull  = Helper.getImage("Inventory/ProgressBarFull");
                float totalHP = selectedChar.LostHP + selectedChar.CurrentHP;
                GUI.DrawTexture(new Rect(571, offset + i * 18, 204, 10),
                                PBEmpty, ScaleMode.ScaleAndCrop);
                GUI.DrawTextureWithTexCoords(new Rect(571, offset + i * 18,
                                                      204 * selectedChar.CurrentHP / totalHP, 10), PBFull,
                                             new Rect(0, 0, selectedChar.CurrentHP / totalHP, 1));
                offset += 10;
                GUI.Label(new Rect(571, offset + i * 18, 150, 23),
                          "Experience");
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                          selectedChar.Exp.ToString() + "/" +
                          selectedChar.nextLevelExp.ToString(), "AttrValues");
                offset += 23;
                GUI.DrawTexture(new Rect(571, offset + i * 18, 204, 10),
                                PBEmpty, ScaleMode.ScaleAndCrop);
                offset -= 3;
            }
            else
            {
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                          secAttr.Value.ToString(), "AttrValues");
            }
        }
    }
Ejemplo n.º 6
0
    void showCharacterInfo(BaseChar selectedChar)
    {
        GUIContent content;

        GUI.DrawTexture(new Rect(567, 29, 76, 84), selectedChar.Image, 
            ScaleMode.ScaleToFit, true);
        GUI.Label(new Rect(648, 29, 150, 20), selectedChar.charName, "title");
        GUI.Label(new Rect(648, 49, 150, 20), 
            "Class: " + selectedChar.CharClass.Name, "title");
        GUI.Label(new Rect(648, 69, 150, 20), "Level: " + selectedChar.level, 
            "title");

        for (int i = 0; i < selectedChar.getAttributes().Length; i++)
        {
            BaseStat attribute = selectedChar.getAttr(i);
            content = new GUIContent(attribute.Name, attribute.description);
            GUI.Label(new Rect(571, 115 + i * 17, 100, 23), content);
            GUI.Label(new Rect(676, 115 + i * 17, 30, 23), 
                attribute.Value.ToString());
        }

        int nrOfPrimaryAttr = System.Enum.GetValues(typeof(AttrNames)).Length;
        int offset = 128 + nrOfPrimaryAttr * 17;
        for (int i = 0; i < selectedChar.getSecondaryAttributes().Length; i++)
        {
            ModifiedStat secAttr = selectedChar.getSecondaryAttr(i);
            string attrName = secAttr.Name.Replace('_', ' ');
            content = new GUIContent(attrName, secAttr.description);
            GUI.Label(new Rect(571, offset + i * 18, 150, 23), content);
            if (i == (int)SecondaryAttrNames.Hit_Points)
            {
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                    selectedChar.CurrentHP.ToString() + "/" +
                    secAttr.Value.ToString(), "AttrValues");
                offset += 23;
                Texture2D PBEmpty, PBFull;
                PBEmpty = Helper.getImage("Inventory/ProgressBarEmpty");
                PBFull = Helper.getImage("Inventory/ProgressBarFull");
                float totalHP = selectedChar.LostHP + selectedChar.CurrentHP;
                GUI.DrawTexture(new Rect(571, offset + i * 18, 204, 10),
                    PBEmpty, ScaleMode.ScaleAndCrop);
                GUI.DrawTextureWithTexCoords(new Rect(571, offset + i * 18,
                    204 * selectedChar.CurrentHP / totalHP, 10), PBFull,
                    new Rect(0, 0, selectedChar.CurrentHP / totalHP, 1));
                offset += 10;
                GUI.Label(new Rect(571, offset + i * 18, 150, 23),
                    "Experience");
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                    selectedChar.Exp.ToString() + "/" +
                    selectedChar.nextLevelExp.ToString(), "AttrValues");
                offset += 23;
                GUI.DrawTexture(new Rect(571, offset + i * 18, 204, 10),
                    PBEmpty, ScaleMode.ScaleAndCrop);
                offset -= 3;
            }
            else
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                    secAttr.Value.ToString(), "AttrValues");
        }
    }