質問編集履歴

5

CardModelの修正を試みた

2024/07/10 11:21

投稿

tomtom369
tomtom369

スコア1

test CHANGED
File without changes
test CHANGED
@@ -48,8 +48,6 @@
48
48
  CardModelはコンポーネントを必要とせず、カードデータとその処理を行う、と説明されていました。
49
49
  以下カードモデルのコードです。
50
50
 
51
- 、、、
52
-
53
51
  using System.Collections;
54
52
  using System.Collections.Generic;
55
53
  using UnityEngine;
@@ -74,5 +72,5 @@
74
72
 
75
73
  }
76
74
  }
77
- 、、、
78
75
 
76
+

4

CardModelの表記の修正を試みた、、

2024/07/10 11:19

投稿

tomtom369
tomtom369

スコア1

test CHANGED
File without changes
test CHANGED
@@ -48,7 +48,7 @@
48
48
  CardModelはコンポーネントを必要とせず、カードデータとその処理を行う、と説明されていました。
49
49
  以下カードモデルのコードです。
50
50
 
51
-
51
+ 、、、
52
52
 
53
53
  using System.Collections;
54
54
  using System.Collections.Generic;
@@ -74,4 +74,5 @@
74
74
 
75
75
  }
76
76
  }
77
+ 、、、
77
78
 

3

参考にした動画のURLを追加

2024/07/10 11:09

投稿

tomtom369
tomtom369

スコア1

test CHANGED
File without changes
test CHANGED
@@ -43,7 +43,7 @@
43
43
  chatGPTで質問したが、よくわからなかったうえ、勝手に変更すると後々困るのではないかと思い、変更していない。
44
44
 
45
45
  ### 補足
46
- ようつべのシャドバ風カードゲームの作り方という動画どうりに作ったつもりです。該当箇所は3番目の動画です。
46
+ ようつべのシャドバ風カードゲームの作り方という動画どうりに作ったつもりです。該当箇所は3番目の動画です。https://www.youtube.com/watch?v=9VtfajLzSrg&list=PLEkX-p0oUs8zRR4MNH1gJuWTmni60IGVm&index=3
47
47
 
48
48
  CardModelはコンポーネントを必要とせず、カードデータとその処理を行う、と説明されていました。
49
49
  以下カードモデルのコードです。

2

CardControllerを質問欄に追加

2024/07/10 11:03

投稿

tomtom369
tomtom369

スコア1

test CHANGED
File without changes
test CHANGED
@@ -19,15 +19,16 @@
19
19
  using System.Collections.Generic;
20
20
  using UnityEngine;
21
21
 
22
- [CreateAssetMenu(fileName = "CardEntity",menuName ="Create CardEntity")]
23
- //カードデータそのもの
24
- public class CardEntity : ScriptableObject
22
+ public class CardController : MonoBehaviour
25
23
  {
24
+ //見かけ(view)に関することを操作
25
+ CardModel model;//データ(model)に関することを操作
26
+
26
- public new string name;
27
+ public void Init(int cardID)
27
- public int hp;
28
+ {
28
- public int at;
29
- public int cost;
30
- public Sprite icon;
29
+ model = new CardModel(cardID);
30
+ }
31
+
31
32
  }
32
33
 
33
34
  ```

1

CardModelについての説明を追加

2024/07/10 09:51

投稿

tomtom369
tomtom369

スコア1

test CHANGED
File without changes
test CHANGED
@@ -43,3 +43,34 @@
43
43
 
44
44
  ### 補足
45
45
  ようつべのシャドバ風カードゲームの作り方という動画どうりに作ったつもりです。該当箇所は3番目の動画です。
46
+
47
+ CardModelはコンポーネントを必要とせず、カードデータとその処理を行う、と説明されていました。
48
+ 以下カードモデルのコードです。
49
+
50
+
51
+
52
+ using System.Collections;
53
+ using System.Collections.Generic;
54
+ using UnityEngine;
55
+
56
+ //カードデータそのものとその処理
57
+ public class CardModel
58
+ {
59
+ public string name;
60
+ public int hp;
61
+ public int at;
62
+ public int cost;
63
+ public Sprite icon;
64
+
65
+ public CardModel()
66
+ {
67
+ CardEntity cardEntity = Resources.Load<CardEntity>("CardEntityList/Card1");
68
+ name = cardEntity.name;
69
+ hp = cardEntity.hp;
70
+ at = cardEntity.at;
71
+ cost = cardEntity.cost;
72
+ icon = cardEntity.icon;
73
+
74
+ }
75
+ }
76
+