コード例 #1
0
    private void Awake()
    {
        JSONNodeReader jsonReader = new JSONNodeReader(fileItems);

        JSONNamedEventReader itemReader = new JSONNamedEventReader("identifier");

        itemReader.AddCallbackInt("health bonus", player.AddMaxHealth, "+{0} health");
        itemReader.AddCallbackInt("tongue damage bonus", player.AddTongueDamage, "+{0} tongue damage");
        itemReader.AddCallbackInt("headbutt damage bonus", player.AddHeadbuttDamage, "+{0} headbutt damage");
        itemReader.AddCallbackInt("laser damage bonus", player.AddLaserDamage, "+{0} laser damage");
        itemReader.AddCallbackInt("contact damage per second bonus", player.AddContactDamagePerSecond, "+{0} contact damage");
        itemReader.AddCallbackInt("damaged explosion damage bonus", player.AddEggExplosionDamage, "+{0} egg damage...?");
        itemReader.AddCallbackInt("headbutt explosion damage bonus", player.AddHeadbuttExplosionDamage, "+{0} headbutt explosion damage");
        itemReader.AddCallbackFloat("jump velocity bonus", player.AddJumpVelocity, "+{0} jump height");
        itemReader.AddCallbackFloat("horizontal acceleration bonus", player.AddHorizontalAcceleration, "+{0} acceleration");
        itemReader.AddCallbackFloat("max horizontal speed bonus", player.AddMaxHorizontalSpeed, "+{0} max speed");
        itemReader.AddCallbackBool("press down for shield", player.SetHasSoap, "Press down for shield");

        JSONArrayReader itemsReader = jsonReader.Get <JSONArrayReader>("items");
        JSONNodeReader  itemNodeReader;

        while (itemsReader.GetNextNode(out itemNodeReader))
        {
            bool blacklist = itemNodeReader.Get("BLACKLIST", false);
            if (!blacklist)
            {
                NamedEvent item = itemReader.Read(itemNodeReader);
                item.AddCallback(() => Claim(item));
                pool.AddUnclaimed(item);
            }
        }
    }
コード例 #2
0
    // Tries to add a callback to the NamedEvent based on the given node name.
    // The callback parameter is assigned the value associated with the node.
    private void TryAddCallback <T>(string nodeName, EventCallback <T> callback)
    {
        T value;

        if (nodeReader.TryGet(nodeName, out value))
        {
            currentEvent.AddCallback(() => callback(value));
        }
    }
コード例 #3
0
    // Tries to add a single-argument callback to the NamedEvent based on
    // the given node name.
    // The callback parameter is assigned the value associated with the node.
    private void TryAddCallback <T>(string nodeName, EventCallback <T> callback)
    {
        T value;

        if (nodeReader.TryGet(nodeName, out value))
        {
            string description = string.Format(nameToDescription[nodeName], value);
            currentEvent.AddCallback(() => callback(value), description);
        }
    }
コード例 #4
0
    private void Awake()
    {
        JSONNodeReader jsonReader = new JSONNodeReader(fileItems);

        JSONNamedEventReader itemReader = new JSONNamedEventReader("identifier");

        itemReader.AddCallbackInt("health bonus", player.AddMaxHealth);
        itemReader.AddCallbackInt("tongue damage bonus", player.AddTongueDamage);
        itemReader.AddCallbackInt("headbutt damage bonus", player.AddHeadbuttDamage);

        JSONArrayReader itemsReader = jsonReader.Get <JSONArrayReader>("items");
        JSONNodeReader  itemNodeReader;

        while (itemsReader.GetNextNode(out itemNodeReader))
        {
            NamedEvent item = itemReader.Read(itemNodeReader);
            item.AddCallback(() => Claim(item));
            pool.AddUnclaimed(item);
        }
    }