You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
namespace ET |
|
{ |
|
[FriendClass(typeof(Menu))] |
|
public static class MenuComponentSystem |
|
{ |
|
public static Menu initMenu(this MenuComponent self, int id) |
|
{ |
|
if (self.CheckoutMenu(id) != 0) |
|
{ |
|
return null; |
|
} |
|
Menu menu= self.Add(id, 0); |
|
menu.Proficiency = 0; |
|
menu.State = Constant.ConstMenuState.NOT_FULL; |
|
return menu; |
|
} |
|
|
|
public static Menu Add(this MenuComponent self, int id, int state) |
|
{ |
|
Menu menu = self.GetChild<Menu>(id); |
|
if (menu == null) |
|
{ |
|
menu = self.AddChildWithId<Menu>(id); |
|
menu.ConfigId = id; |
|
menu.Proficiency = 0; |
|
menu.State = Constant.ConstMenuState.NOT_FULL; |
|
} |
|
|
|
var prof = menu.Config.ProficiencyPerItem; |
|
if (state == 2 && menu.Config.QualityProficiencyPerItem > 0) |
|
{ |
|
prof = menu.Config.QualityProficiencyPerItem; |
|
} |
|
|
|
menu.Proficiency += prof; |
|
if (menu.Proficiency >= menu.Config.NeedProficiency) |
|
{ |
|
menu.State = Constant.ConstMenuState.FULL; |
|
} |
|
return menu; |
|
} |
|
|
|
public static int CheckoutMenu(this MenuComponent self, int id) |
|
{ |
|
Menu menu = self.GetChild<Menu>(id); |
|
if (menu == null) |
|
{ |
|
return 0; |
|
} |
|
|
|
return menu.State; |
|
} |
|
|
|
|
|
} |
|
} |