Ejemplo n.º 1
0
    /*
     * Checking active player attribute.
     * By default, if min value not met, stopping skill chain.
     * If self is true, the attribute of the currently active character will be checked. Otherwise the attributes of all selected characters will be checked.
     * Attribute id is the id of the attribute to check (of the latter character).
     * Min Value is the minimum value that the attribute can have. If the value of the attribute is below the minimum value, the skill chain will be stopped.
     */
    void checkAttribute(bool self, int attrId, float minValue)
    {
        if (self)
        {
            //Active char id
            var activeCharId = BattleManager.core.activeCharacterId;

            //Getting character
            character character = Database.core.characters[FunctionDB.core.findCharacterIndexById(activeCharId)];

            //Getting attribute
            characterAttribute attribute = character.characterAttributes[FunctionDB.core.findAttributeIndexById(attrId, character)];

            //Checking value
            if (attribute.curValue < minValue)
            {
                //Stopping skill chain and displaying warning
                BattleManager.core.functionQueue.Clear();
                BattleManager.core.startWarningRoutine("Not enough " + attribute.name, 2f);
            }
        }
        else
        {
            //For each action target
            foreach (int target in BattleManager.core.actionTargets)
            {
                //Getting character
                character character = Database.core.characters[FunctionDB.core.findCharacterIndexById(target)];

                //Getting attribute
                characterAttribute attribute = character.characterAttributes[FunctionDB.core.findAttributeIndexById(attrId, character)];

                //Checking value
                if (attribute.curValue < minValue)
                {
                    //Stopping skill chain and displaying warning
                    BattleManager.core.functionQueue.Clear();
                    BattleManager.core.startWarningRoutine("Not enough " + attribute.name, 2f);
                    break;
                }
            }
        }



        BattleManager.core.setQueueStatus("checkAttribute", false);
    }
Ejemplo n.º 2
0
    //This function displays and continuously update attributes in the battle area
    IEnumerator battleAreahealthManager(int charId, float yOffset)
    {
        //Getting character by id
        character character = Database.core.characters [FunctionDB.core.findCharacterIndexById(charId)];
        //Getting character instance by id
        GameObject characterInstance = FunctionDB.core.findCharInstanceById(charId);
        //Getting attribute index
        int charAttrIndx = FunctionDB.core.findAttributeIndexById(0, character);
        //Getting prefab
        GameObject valuePrefab = ObjectDB.core.battleUIValuePrefab;
        //Getting UI area
        GameObject spawnArea = ObjectDB.core.battleUIBody;

        //Adjusted position
        Vector3 pos    = characterInstance.transform.position;
        Vector3 newPos = new Vector3(pos.x, pos.y + yOffset, pos.z);

        //Spawning
        GameObject t = Instantiate(valuePrefab, newPos, Quaternion.identity, spawnArea.transform);

        //Displaying info
        while (true)
        {
            //Remove object?
            if (characterInstance == null)
            {
                Destroy(t);
                break;
            }

            //Adjusting coordinates
            pos    = characterInstance.transform.position;
            newPos = new Vector3(pos.x, pos.y + yOffset, pos.z);
            t.transform.position = newPos;

            //Updating text
            characterAttribute attr = character.characterAttributes[charAttrIndx];
            t.GetComponent <Text>().text = attr.curValue.ToString() + "/" + attr.maxValue.ToString();
            yield return(new WaitForEndOfFrame());
        }
    }
Ejemplo n.º 3
0
    /*
     * This function allows to change any of the active player or target attributes.
     * Attribute id is the id of the attribute to change.
     * The value is a string which represents the modification.
     * Writing +10, for example will add 10 units to the attribute, while writing -10 will subtract 10.
     * However, writing simply 10 will result into the attribute being set to 10.
     * If self is true, the attribute of the currently active character will be modified. However, if self is false, the attributes (with teh specified ids) of all
     * selected targets will be modified.
     */
    void changeAttribute(bool self, int attrId, string value)
    {
        //This function converts a string to an expression and assings the derived value to the attribute
        float v;
        bool  set = false;

        switch (value.Substring(0, 1))
        {
        case "-":
            v = -float.Parse(value.Substring(1));
            break;

        case "+":
            v = float.Parse(value.Substring(1));
            break;

        default:
            v   = float.Parse(value);
            set = true;
            break;
        }

        if (self)
        {
            //Active char id
            var activeCharId = BattleManager.core.activeCharacterId;

            //Displaying change
            FunctionDB.core.StartCoroutine(FunctionDB.core.displayValue(FunctionDB.core.findCharInstanceById(activeCharId), v, 0, 0.3f));

            //Getting character
            character character = Database.core.characters[FunctionDB.core.findCharacterIndexById(activeCharId)];
            //Getting attribute
            characterAttribute attribute = character.characterAttributes[FunctionDB.core.findAttributeIndexById(attrId, character)];

            //Applying change
            if (!set)
            {
                attribute.curValue = (attribute.curValue + v) > 0 ? (attribute.curValue + v) : 0;
            }
            else
            {
                attribute.curValue = v > 0 ? v : 0;
            }
        }
        else
        {
            //For each action target
            foreach (int target in BattleManager.core.actionTargets)
            {
                //Displaying change
                FunctionDB.core.StartCoroutine(FunctionDB.core.displayValue(FunctionDB.core.findCharInstanceById(target), v, 0, 0.3f));

                //Getting character
                character character = Database.core.characters[FunctionDB.core.findCharacterIndexById(target)];

                //Making sure that the specific target has that attribute
                if (FunctionDB.core.findAttributeIndexById(attrId, character) > -1)
                {
                    characterAttribute attribute = character.characterAttributes[FunctionDB.core.findAttributeIndexById(attrId, character)];

                    //Applying change
                    if (!set)
                    {
                        attribute.curValue = (attribute.curValue + v) > 0 ? (attribute.curValue + v) : 0;
                    }
                    else
                    {
                        attribute.curValue = v > 0 ? v : 0;
                    }
                }
            }
        }

        BattleManager.core.setQueueStatus("changeAttribute", false);
    }