예제 #1
0
    /// <summary>
    /// Outputs an attack, controlled by an attack system. Intended to be activated when the attack went through. Can not be activated by Value-like nodes.
    /// </summary>
    public static void SetState_OutNode(Node prevNode, Node node, ref NodeGraph graph, bool state, float baseval)
    {
        if (node.Active)
        {
            return;
        }

        if (IsValueHoldingNode(prevNode))
        {
            return;
        }
        node.Active = state;

        int id     = graph.GetIdFromNode(node);
        var spd    = .001f;
        var dmg    = .001f;
        var type   = 0f;
        var status = -1f;

        foreach (var potentialAffector in graph.NodeDict)
        {
            if (!potentialAffector.Value.ConnectedNodes.Contains(id))
            {
                continue;
            }
            switch (potentialAffector.Value.Node_text)
            {
            case "DMG":
                dmg = Mathf.Max(dmg, potentialAffector.Value.Value);
                continue;

            case "SPD":
                spd = Mathf.Max(spd, potentialAffector.Value.Value);
                continue;

            case "TYPE":
                type = potentialAffector.Value.Value;
                continue;

            case "STAT":
                status = potentialAffector.Value.Value;
                break;

            default:
                continue;
            }
        }
        // checks if the attack can go trough, if it can't this node won't activate
        node.Active = PlayerAttacks.ProccessAttackNode(spd, dmg, (int)type, node, (int)status);
        if (Callbacks.Count != 0 && Callbacks.Peek().Activator == null)
        {
            Callbacks.Peek().Activator = node;
        }
    }