0

I have got an Enum List

public enum SkillName {
    Mele_Offence,
    Mele_Defence
}

Then my skills are setted up and modified on Player class

private void SetupSkillModifires () {
        // mele Offence
        GetSkill((int)SkillName.Mele_Offence).AddModifire(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Strength), 2));
        GetSkill((int)SkillName.Mele_Offence).AddModifire(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Agility), 1));
        //mele Deffence 
        GetSkill((int)SkillName.Mele_Defence).AddModifire(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Agility), 1));
        GetSkill((int)SkillName.Mele_Defence).AddModifire(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Vitality), 2));
        //Magic Offence

    }

Then I have converted it to string and displayed it in scene.

private void DisplayAttributes() {
        for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
            GUI.Label (new Rect (130, 60 + (cnt * 20), 100, 20), ((AttributeName)cnt).ToString());
            GUI.Label (new Rect (300, 60 + (cnt * 20), 30, 25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());
            if (GUI.Button (new Rect (265, 60 + (cnt * 20), 20, 20), "-")) {
                if (_toon.GetPrimaryAttribute(cnt).BaseValue > MIN_STARTING_ATTRIBUTE_VALUE) {
                    _toon.GetPrimaryAttribute (cnt).BaseValue--;
                    pointsLeft++;
                    _toon.StatUpdate ();
                }

How to assign theese skills to Player attack value? I have this error. error CS0029: Cannot implicitly convert type Skil to int?

Kamil Solecki
  • 1,106
  • 20
  • 34
  • At which line you get that exception? Funny thing is what you already using casting (e.g. `(int)AttributeName.Vitality`), haven't you thought to use cast at that line too? – Sinatr Jun 07 '16 at 10:01
  • `Skil` isn't the same as `SkilName` The error message refers to `Skil`, which I am assuming is not an enum. – Keith Payne Jun 07 '16 at 10:03
  • currentAttack = _toon.GetSkil((int)SkilName.Mele_Offence) Where currentAttack is private int currentAttack; – Dimon Olenov Jun 07 '16 at 10:05
  • Skil is the class Where Enum is. – Dimon Olenov Jun 07 '16 at 10:07
  • All this code works correctly. I just cant Make my Mele_Offence equal to currentAttack which is int. – Dimon Olenov Jun 07 '16 at 10:09
  • The error is pretty straightforward. Your code is attempting to use an object of type `Skil` in a place that expects an `int`. I suspect it is an int argument somewhere in the nested function calls. – Keith Payne Jun 07 '16 at 10:10

0 Answers0