-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPart2CostRender_Right.cs
More file actions
363 lines (334 loc) · 8.74 KB
/
Copy pathPart2CostRender_Right.cs
File metadata and controls
363 lines (334 loc) · 8.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
using BepInEx;
using BepInEx.Logging;
using DiskCardGame;
using UnityEngine;
using HarmonyLib;
using System.Collections.Generic;
using Art = RenderFixMaybe.Resources.costs;
namespace RenderFixMaybe
{
public class Part2CostRender_Right
{
public static float Yposition = 0.85f;
public static float Xposition = 0.4f;
public static float pixelPerUnity = 100.0f;
public static Vector2 vector = new Vector2(Xposition, Yposition);
public static Sprite LoadSpriteFromResource(byte[] resourceFile)
{
var texture = new Texture2D(2, 2);
texture.LoadImage(resourceFile);
texture.filterMode = FilterMode.Point;
var sprite = UnityEngine.Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), vector, pixelPerUnity);
return sprite;
}
public static Sprite MakeSpriteFromTexture2D(Texture2D texture)
{
Sprite sprite;
float Ytest = 0.75f;
float Xtest = 0.52f;
float ppu = 100.0f;
Vector2 vec = new Vector2(Xtest, Ytest);
sprite = UnityEngine.Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), vec, ppu);
return sprite;
}
public static Texture2D LoadTextureFromResource(byte[] resourceFile)
{
var texture = new Texture2D(2, 2);
texture.LoadImage(resourceFile);
texture.filterMode = FilterMode.Point;
return texture;
}
public static Texture2D CombineTextures(List<Texture2D> abilities, List<Vector2Int> patchlocations, byte[] resource)
{
bool flag = abilities != null;
Texture2D result;
if (flag)
{
Texture2D texture2D2 = LoadTextureFromResource(resource);
for (int j = 0; j < abilities.Count; j++)
{
int index = j;
texture2D2.SetPixels(patchlocations[index].x, patchlocations[index].y, abilities[index].width, abilities[index].height, abilities[index].GetPixels(), 0);
}
texture2D2.Apply();
result = texture2D2;
}
else
{
result = null;
}
return result;
}
public static Texture2D GetFinalTexture(int cardCost, byte[] resource)
{
var pixelCost = new List<Vector2Int>();
Texture2D textCost = LoadTextureFromResource(Art.pixel_blank);
List<Texture2D> list = new List<Texture2D>();
Texture2D artCost = LoadTextureFromResource(resource);
list.Add(artCost);
var gemTotal = new List<Vector2Int>();
switch (cardCost)
{
case 1:
textCost = LoadTextureFromResource(Art.pixel_mox_empty);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(23, 0),
new Vector2Int(3, 0)
};
break;
case 2:
textCost = LoadTextureFromResource(Art.pixel_L_2);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 3:
textCost = LoadTextureFromResource(Art.pixel_L_3);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 4:
textCost = LoadTextureFromResource(Art.pixel_L_4);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 5:
textCost = LoadTextureFromResource(Art.pixel_L_5);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 6:
textCost = LoadTextureFromResource(Art.pixel_L_6);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 7:
textCost = LoadTextureFromResource(Art.pixel_L_7);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 8:
textCost = LoadTextureFromResource(Art.pixel_L_8);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 9:
textCost = LoadTextureFromResource(Art.pixel_L_9);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(9, 0),
new Vector2Int(16, 0)
};
break;
case 10:
textCost = LoadTextureFromResource(Art.pixel_L_10);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(3, 0),
new Vector2Int(10, 0)
};
break;
case 11:
textCost = LoadTextureFromResource(Art.pixel_L_11);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(3, 0),
new Vector2Int(10, 0)
};
break;
case 12:
textCost = LoadTextureFromResource(Art.pixel_L_12);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(3, 0),
new Vector2Int(10, 0)
};
break;
case 13:
textCost = LoadTextureFromResource(Art.pixel_L_13);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(3, 0),
new Vector2Int(10, 0)
};
break;
case 14:
textCost = LoadTextureFromResource(Art.pixel_L_14);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(3, 0),
new Vector2Int(10, 0)
};
break;
case 15:
textCost = LoadTextureFromResource(Art.pixel_L_15);
list.Add(textCost);
pixelCost = new List<Vector2Int>
{
new Vector2Int(3, 0),
new Vector2Int(10, 0)
};
break;
}
Texture2D finalBloodTexture = CombineTextures(list, pixelCost, Art.pixel_blank);
return finalBloodTexture;
}
public static Sprite Part2SpriteFinal(CardInfo card)
{
//A list to hold the textures (important later, to combine them all)
List<Texture2D> masterList = new List<Texture2D>();
int bloodCost = card.BloodCost;
int boneCost = card.BonesCost;
int energyCost = card.energyCost;
int moxCost = card.gemsCost.Count;
if (bloodCost > 0)
{
Texture2D texBloodCost = GetFinalTexture(bloodCost, Art.pixel_blood);
masterList.Add(texBloodCost);
}
if (boneCost > 0)
{
Texture2D texBoneCcost = GetFinalTexture(boneCost, Art.pixel_bone);
masterList.Add(texBoneCcost);
}
if (energyCost > 0)
{
Texture2D texEnergyCost = GetFinalTexture(energyCost, Art.pixel_energy);
masterList.Add(texEnergyCost);
}
if (moxCost > 0)
{
List<Texture2D> gemCost = new List<Texture2D>();
//If a card has a green mox, set the green mox
if (card.GemsCost.Contains(GemType.Green))
{
Texture2D green = LoadTextureFromResource(Art.pixel_mox_green);
gemCost.Add(green);
}
//If a card has a green mox, set the Orange mox
if (card.GemsCost.Contains(GemType.Orange))
{
Texture2D orange = LoadTextureFromResource(Art.pixel_mox_red);
gemCost.Add(orange);
}
//If a card has a green mox, set the Blue mox
if (card.GemsCost.Contains(GemType.Blue))
{
Texture2D blue = LoadTextureFromResource(Art.pixel_mox_blue);
gemCost.Add(blue);
}
var gemCounting = gemCost.Count;
var gemTotal = new List<Vector2Int>();
switch (gemCounting)
{
case 1:
gemTotal = new List<Vector2Int>
{
new Vector2Int(22, 0)
};
break;
case 2:
gemTotal = new List<Vector2Int>
{
new Vector2Int(22, 0),
new Vector2Int(15, 0)
};
break;
case 3:
gemTotal = new List<Vector2Int>
{
new Vector2Int(22, 0),
new Vector2Int(14, 0),
new Vector2Int(6, 0)
};
break;
}
Texture2D finalMoxTexture = CombineTextures(gemCost, gemTotal, Art.pixel_blank);
masterList.Add(finalMoxTexture);
}
var counting = masterList.Count;
var total = new List<Vector2Int>();
switch (counting)
{
case 0:
Texture2D blankCost = LoadTextureFromResource(Art.pixel_blank);
masterList.Add(blankCost);
total = new List<Vector2Int>
{
new Vector2Int(0, 0)
};
break;
case 1:
total = new List<Vector2Int>
{
new Vector2Int(0, 24)
};
break;
case 2:
total = new List<Vector2Int>
{
new Vector2Int(0, 16),
new Vector2Int(0, 24)
};
break;
case 3:
total = new List<Vector2Int>
{
new Vector2Int(0, 8),
new Vector2Int(0, 16),
new Vector2Int(0, 24)
};
break;
case 4:
total = new List<Vector2Int>
{
new Vector2Int(0, 0),
new Vector2Int(0, 8),
new Vector2Int(0, 16),
new Vector2Int(0, 24)
};
break;
}
//Combine all the textures from the list into one texture
Texture2D finalTexture = CombineTextures(masterList, total, Art.pixel_base);
//Convert the final texture to a sprite
Sprite finalSprite = MakeSpriteFromTexture2D(finalTexture);
return finalSprite;
}
}
}