コード例 #1
0
    //Attempts to increase level of passive passed in. Upon failure,
    //will return -1 if the user lacks available points and
    //            -2 if the passive is max level
    //             1 upon success
    //            -3 if prerequisite not met
    public int addPointToSkill(Passives passiveID)
    {
        if(availablePoints <= 0)
        {
            Debug.Log("Insufficient points!");
            return -1;
        }

        if (passiveLevel[(int)passiveID] < passiveMaxLevel[(int)passiveID]){
            Debug.Log("Increasing passive level!");
            passiveLevel[(int)passiveID]++;
            availablePoints--;
        }else{
            Debug.Log("Passive has reached max level!");
            return -2;
        }

        //Begin very long chain of ugly if statements that are probably far more comprehensable than
        //the equivelent would have been using classes
        switch (passiveID)
        {
            case Passives.StrengthBonus:
                player.AddBonusPercentStrength(5);    //5% strength per level
                break;

            case Passives.AgilityBonus:
                player.AddBonusPercentAgility(5);     //5% agility per level
                break;
            case Passives.IntelligenceBonus:
                player.AddBonusIntelligence(5);         //5% intelligence per level
                break;
            case Passives.HealthBonus:
                //Check for preRequisits
                if (passiveLevel[(int)Passives.StrengthBonus] > 0)
                {
                    health.addBonusPercentHP(15);      //15% health per level
                    Debug.Log("Running HealthBonus logic!");
                }
                else
                    return -3;

                break;
            case Passives.ManaBonus:
                mana.addBonusPercentMana(20);       //20% mana per level
                break;

        }
        return 1;
    }