Esempio n. 1
0
        //private void LoadAbility(Type abilityType, string name, string description, string texturePath)
        //{
        //    var abilityInfo = AbilityManager.New(PluginInfo.PLUGIN_GUID, name, description, abilityType, texturePath);
        //    abilityInfo.SetDefaultPart1Ability();
        //}

        private void LoadAbility(Type abilityType, string name, string description, string texturePath, string dialogue = "")
        {
            AbilityInfo abilityInfo = ScriptableObject.CreateInstance <AbilityInfo>();

            abilityInfo.powerLevel   = 0;
            abilityInfo.rulebookName = name;
            Traverse.Create(abilityInfo).Field("rulebookDescription").SetValue(description);
            abilityInfo.metaCategories = new List <AbilityMetaCategory> {
                AbilityMetaCategory.Part1Modular, AbilityMetaCategory.Part1Rulebook
            };
            abilityInfo.opponentUsable = true;

            if (dialogue.Length > 0)
            {
                abilityInfo.abilityLearnedDialogue = new DialogueEvent.LineSet(
                    new List <DialogueEvent.Line> {
                    new DialogueEvent.Line {
                        text = "dialogue"
                    }
                }
                    );
            }

            abilityInfo.canStack = false;
            var texture    = LoadTextureFromFile(texturePath);
            var abilityId  = AbilityIdentifier.GetAbilityIdentifier(PluginInfo.PLUGIN_GUID, abilityInfo.rulebookName);
            var newAbility = new NewAbility(abilityInfo, abilityType, texture, abilityId);

            Traverse.Create(abilityType).Field("ability").SetValue(newAbility.ability);
        }
Esempio n. 2
0
 public Ability GetAbility(AbilityIdentifier id)
 {
     for (int i = 0; i < abilities.Length; ++i)
     {
         if (abilities[i].id == id)
         {
             return(abilities[i]);
         }
     }
     Debug.Log("Ability with id: " + id + " not found!");
     return(null);
 }
Esempio n. 3
0
 public void Learn(AbilityIdentifier id)
 {
     if (IsAvailable(id))
     {
         for (int i = 0; i < tree.Count; ++i)
         {
             for (int i2 = 0; i2 < tree[i].branch.Count; ++i2)
             {
                 if (tree[i].branch[i2].ID == id)
                 {
                     tree[i].branch[i2].learned = true;
                 }
             }
         }
     }
 }
Esempio n. 4
0
    public bool IsAvailable(AbilityIdentifier id)
    {
        int branchIndex  = -1;
        int abilityIndex = -1;

        for (int i = 0; i < tree.Count; ++i)
        {
            for (int i2 = 0; i2 < tree[i].branch.Count; ++i2)
            {
                if (tree[i].branch[i2].ID == id)
                {
                    if (tree[i].branch[i2].learned)
                    {
                        return(false);
                    }
                    branchIndex  = i;
                    abilityIndex = i2;
                    break;
                }
            }
            if (branchIndex != -1)
            {
                break;
            }
        }
        int targetTier = tree[branchIndex].branch[abilityIndex].tier;

        for (int i = 0; i < tree[branchIndex].branch.Count; ++i)
        {
            if (tree[branchIndex].branch[i].tier == targetTier - 1 && !tree[branchIndex].branch[i].learned)
            {
                return(false);
            }
        }
        return(true);
    }
Esempio n. 5
0
 public AbilityInBranch(AbilityIdentifier _ID, bool _learned, int _tier)
 {
     ID      = _ID;
     learned = _learned;
     tier    = _tier;
 }