Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / buff / effect / Eff_GetGold.cs
@小李xl 小李xl on 22 Mar 2024 788 bytes 道具逻辑片段更新参数描述


using System.Text.Json;
using Godot;

[EffectFragment(
    "GetGold",
    "获得金币",
    Arg1 = "(int)金币的值"
)]
public class Eff_GetGold : EffectFragment
{
    private int _value;
    public override void InitParam(JsonElement[] args)
    {
        _value = args[0].GetInt32();
    }

    public override void OnUse()
    {
        var goldList = Utils.GetGoldList(Mathf.FloorToInt(_value));
        foreach (var id in goldList)
        {
            var o = ObjectManager.GetActivityObject<Gold>(id);
            o.Position = Role.Position;
            o.Throw(0,
                Utils.Random.RandomRangeInt(50, 110),
                new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)),
                0
            );
        }
    }
}