public Button(string name, Form1.Fn fn, int usetime = 1, bool CanLostInDark = true, bool CanLostCook = true, string prefabname = null, bool GotoNextState = false, double rate = 0.5) { this.name = name; this.maxusetime = this.usetime = usetime; this.prefabname = prefabname; this.fn = (object sender, EventArgs e) => { if (CanLostInDark && Worldtime.GetState() == "晚上" && !Form1.traveler.HasTag("light")) { g_baseresult.LostInDark(); } else { if (this.usetime > 0) //注意不能直接用 usetime-- !!!,因为它是指传入的参数 { --this.usetime; if (fn != null) { fn(); } if (this.usetime <= 0) { if (linkbutton != null) { linkbutton.Enabled = false; } } } if (CanLostCook) { MainForm.DeCookMenu(); } } if (GotoNextState) { Worldtime.GotoNextState(rate); } }; }
public void AddButton(string name, Form1.Fn fn, int usetime = 1, bool CanLostInDark = true, bool CanLostCook = true, string prefabname = null, bool GotoNextState = false) { Button button = new Button(name, fn, usetime, CanLostInDark, CanLostCook, prefabname, GotoNextState); AddButton(button); }
public void SetLeavefn(Form1.Fn fn) { this.leavefn = (Scane who) => { fn(); }; }
public void SetEnterfn(Form1.Fn fn) { this.enterfn = (Scane who) => { fn(); }; }