@@ -31,7 +31,7 @@ internal class ShopUI : UIState
3131 public const int WITCHDOCTOR = 23 ;
3232 public const int WIZARD = 24 ;
3333
34- public static Dictionary < int , Shop > Shops = new ( ) {
34+ static readonly Dictionary < int , Shop > shops = new ( ) {
3535 // DO NOT CHANGE THESE NAMES WITHOUT CHECKING THAT THEY MATCH
3636 // CORRECTLY INSIDE THEIR RESPECTIVE SHOP CLASSES!
3737 { ANGLER , new ShopAngler ( "Bait" , "Buffs" , "Crates" ) } ,
@@ -66,50 +66,51 @@ internal class ShopUI : UIState
6666 } ;
6767
6868 public static bool Visible { get ; set ; }
69-
7069 public static int CurrentShopIndex { get ; set ; }
71- public static int [ ] ShopCycleIndexes { get ; } = new int [ Shops . Count ] ;
72-
73- public string [ ] ShopNames { get ; } = new string [ Shops . Count ] ;
74- public UIText CurrentShopName { get ; set ; }
70+ public static int [ ] ShopCycleIndexes { get ; private set ; }
7571
76- UIPanel ShopPanel ;
72+ string [ ] shopNames ;
73+ UIText currentShopName ;
74+ UIPanel shopPanel ;
7775
7876 public override void OnInitialize ( )
7977 {
78+ ShopCycleIndexes = new int [ shops . Count ] ;
79+ shopNames = new string [ shops . Count ] ;
80+
8081 // This is the first shop name the player will see (for all shops)
8182 // before pressing cycle shop button
82- for ( int i = 0 ; i < Shops . Count ; i ++ )
83- ShopNames [ i ] = Shops [ i ] . ToString ( ) ;
83+ for ( int i = 0 ; i < shops . Count ; i ++ )
84+ shopNames [ i ] = shops [ i ] . ToString ( ) ;
8485
8586 //for (int i = 0; i < ShopNames.Length; i++)
8687 // ShopNames[i] = "Shop";
8788
88- ShopPanel = new UIPanel ( ) ;
89- ShopPanel . SetPadding ( 0 ) ;
90- ShopPanel . Left . Set ( 200f , 0f ) ;
91- ShopPanel . Top . Set ( 428f , 0f ) ;
92- ShopPanel . Width . Set ( 250f , 0f ) ;
93- ShopPanel . Height . Set ( 35f , 0f ) ;
94- ShopPanel . BackgroundColor = new Color ( 0 , 0 , 0 , 0.6f ) ;
89+ shopPanel = new UIPanel ( ) ;
90+ shopPanel . SetPadding ( 0 ) ;
91+ shopPanel . Left . Set ( 200f , 0f ) ;
92+ shopPanel . Top . Set ( 428f , 0f ) ;
93+ shopPanel . Width . Set ( 250f , 0f ) ;
94+ shopPanel . Height . Set ( 35f , 0f ) ;
95+ shopPanel . BackgroundColor = new Color ( 0 , 0 , 0 , 0.6f ) ;
9596
96- CurrentShopName = new UIText ( ShopNames [ CurrentShopIndex ] , 0.9f ) ;
97- CurrentShopName . Left . Set ( 10 , 0f ) ;
98- CurrentShopName . Top . Set ( 8 , 0f ) ;
99- CurrentShopName . OnLeftClick += new MouseEvent ( ShopButtonClicked ) ;
100- ShopPanel . Append ( CurrentShopName ) ;
97+ currentShopName = new UIText ( shopNames [ CurrentShopIndex ] , 0.9f ) ;
98+ currentShopName . Left . Set ( 10 , 0f ) ;
99+ currentShopName . Top . Set ( 8 , 0f ) ;
100+ currentShopName . OnLeftClick += new MouseEvent ( ShopButtonClicked ) ;
101+ shopPanel . Append ( currentShopName ) ;
101102
102103 var cycleShopButton = new TextButton ( "Cycle Shop" , 0.9f ) ;
103104 cycleShopButton . Left . Set ( 150 , 0f ) ;
104105 cycleShopButton . Top . Set ( 4 , 0f ) ;
105106 cycleShopButton . OnLeftClick += new MouseEvent ( CycleShopButtonClicked ) ;
106- ShopPanel . Append ( cycleShopButton ) ;
107+ shopPanel . Append ( cycleShopButton ) ;
107108
108- Append ( ShopPanel ) ;
109+ Append ( shopPanel ) ;
109110 }
110111
111112 public void UpdateShopName ( ) =>
112- CurrentShopName . SetText ( ShopNames [ CurrentShopIndex ] ) ;
113+ currentShopName . SetText ( shopNames [ CurrentShopIndex ] ) ;
113114
114115 void CycleShopButtonClicked ( UIMouseEvent evt , UIElement listeningElement )
115116 {
@@ -120,21 +121,21 @@ void CycleShopButtonClicked(UIMouseEvent evt, UIElement listeningElement)
120121
121122 void ShiftShop ( )
122123 {
123- if ( Shops [ CurrentShopIndex ] . Shops . Count == 0 ) return ; // Safe Guard
124- if ( ShopCycleIndexes [ CurrentShopIndex ] >= Shops [ CurrentShopIndex ] . Shops . Count - 1 )
124+ if ( shops [ CurrentShopIndex ] . Shops . Count == 0 ) return ; // Safe Guard
125+ if ( ShopCycleIndexes [ CurrentShopIndex ] >= shops [ CurrentShopIndex ] . Shops . Count - 1 )
125126 {
126- ShopNames [ CurrentShopIndex ] = Shops [ CurrentShopIndex ] . Shops [ 0 ] ;
127+ shopNames [ CurrentShopIndex ] = shops [ CurrentShopIndex ] . Shops [ 0 ] ;
127128 ShopCycleIndexes [ CurrentShopIndex ] = 0 ;
128129 }
129130 else
130131 {
131- ShopNames [ CurrentShopIndex ] = Shops [ CurrentShopIndex ] . Shops [ ++ ShopCycleIndexes [ CurrentShopIndex ] ] ;
132+ shopNames [ CurrentShopIndex ] = shops [ CurrentShopIndex ] . Shops [ ++ ShopCycleIndexes [ CurrentShopIndex ] ] ;
132133 }
133134 }
134135
135136 void ShopButtonClicked ( UIMouseEvent evt , UIElement listeningElement ) =>
136137 OpenShop ( ) ;
137138
138139 void OpenShop ( ) =>
139- Shops [ CurrentShopIndex ] . OpenShop ( ShopNames [ CurrentShopIndex ] ) ;
140+ shops [ CurrentShopIndex ] . OpenShop ( shopNames [ CurrentShopIndex ] ) ;
140141}
0 commit comments