回答編集履歴

1

PopulateWithInfoメソッドを追記

2018/05/01 01:11

投稿

imohori708
imohori708

スコア10

test CHANGED
@@ -1,6 +1,8 @@
1
1
  追記です。
2
2
 
3
- Cardクラスの中身を下記に記します
3
+ CardクラスとPopulateWithInfoメソッドそれぞれを下記に記します
4
+
5
+ 以下、カードクラス。
4
6
 
5
7
  ```C#
6
8
 
@@ -205,3 +207,161 @@
205
207
 
206
208
 
207
209
  ```
210
+
211
+
212
+
213
+ 続いてPopulateWithInfoメソッド
214
+
215
+ ```C#
216
+
217
+ public virtual void PopulateWithInfo(RuntimeCard card)
218
+
219
+ {
220
+
221
+ this.card = card;
222
+
223
+
224
+
225
+ //ゲームの基本設定
226
+
227
+ var gameConfig = GameManager.Instance.config;
228
+
229
+ //カードのID一覧
230
+
231
+ var libraryCard = gameConfig.GetCard(card.cardId);
232
+
233
+ Assert.IsNotNull(libraryCard);
234
+
235
+ //カードの名前
236
+
237
+ nameText.text = libraryCard.name;
238
+
239
+
240
+
241
+ attackStat = card.namedStats["Attack"];
242
+
243
+ healthStat = card.namedStats["Life"];
244
+
245
+ attackText.text = attackStat.effectiveValue.ToString();
246
+
247
+ healthText.text = healthStat.effectiveValue.ToString();
248
+
249
+
250
+
251
+ pictureSprite.sprite = Resources.Load<Sprite>(string.Format("Images/{0}", libraryCard.GetStringProperty("Picture")));
252
+
253
+ var material = libraryCard.GetStringProperty("Material");
254
+
255
+ if (!string.IsNullOrEmpty(material))
256
+
257
+ {
258
+
259
+ pictureSprite.material = Resources.Load<Material>(string.Format("Materials/{0}", material));
260
+
261
+ }
262
+
263
+
264
+
265
+ onAttackStatChangedDelegate = (oldValue, newValue) =>
266
+
267
+ {
268
+
269
+ UpdateStatText(attackText, attackStat);
270
+
271
+ };
272
+
273
+ attackStat.onValueChanged += onAttackStatChangedDelegate;
274
+
275
+
276
+
277
+ onHealthStatChangedDelegate = (oldValue, newValue) =>
278
+
279
+ {
280
+
281
+ UpdateStatText(healthText, healthStat);
282
+
283
+ };
284
+
285
+ healthStat.onValueChanged += onHealthStatChangedDelegate;
286
+
287
+
288
+
289
+ //キーワードについての挙動
290
+
291
+ //属性追加時にいじるとこ(後日要編集)
292
+
293
+ var subtypes = gameConfig.keywords.Find(x => x.name == "Subtypes");
294
+
295
+ var impetus = subtypes.values.FindIndex(x => x.value == "Impetus");
296
+
297
+ var provoke = subtypes.values.FindIndex(x => x.value == "Provoke");
298
+
299
+ foreach (var keyword in libraryCard.keywords)
300
+
301
+ {
302
+
303
+ if (keyword.keywordId == subtypes.id)
304
+
305
+ {
306
+
307
+ if (keyword.valueId == impetus)
308
+
309
+ {
310
+
311
+ hasImpetus = true;
312
+
313
+ }
314
+
315
+ else if (keyword.valueId == provoke)
316
+
317
+ {
318
+
319
+ hasProvoke = true;
320
+
321
+ }
322
+
323
+ }
324
+
325
+ }
326
+
327
+
328
+
329
+ if (hasProvoke)
330
+
331
+ {
332
+
333
+ glowSprite.gameObject.SetActive(false);
334
+
335
+ shadowSprite.gameObject.SetActive(false);
336
+
337
+ shieldGlowSprite.gameObject.SetActive(true);
338
+
339
+ shieldShadowSprite.gameObject.SetActive(true);
340
+
341
+ shieldSprite.gameObject.SetActive(true);
342
+
343
+ }
344
+
345
+ SetHighlightingEnabled(false);
346
+
347
+ if (hasImpetus)
348
+
349
+ {
350
+
351
+ StopSleepingParticles();
352
+
353
+ if (ownerPlayer != null)
354
+
355
+ {
356
+
357
+ SetHighlightingEnabled(true);
358
+
359
+ isPlayable = true;
360
+
361
+ }
362
+
363
+ }
364
+
365
+ }
366
+
367
+ ```