Created
February 9, 2020 03:18
-
-
Save gremito/564e5dff3b5c98deaa80315c04e9c494 to your computer and use it in GitHub Desktop.
Dealer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Dealer : MonoBehaviour | |
{ | |
/// <summary> | |
/// カードの種類とカードのGameObjectを一緒に管理 | |
/// </summary> | |
Dictionary<int, GameObject> cards; | |
/// <summary> | |
/// カードのGameObject(プレハブ) | |
/// </summary> | |
[SerializeField] | |
private List<GameObject> cardPrefabs; | |
/// <summary> | |
/// 場に出ているカードのGameObject(クローン) | |
/// </summary> | |
private List<GameObject> fieldCards; | |
void Start() | |
{ | |
// カード情報の初期化 | |
cards = new Dictionary<int, GameObject>(); | |
cards.Add(0, cardPrefabs[0]); | |
cards.Add(1, cardPrefabs[1]); | |
cards.Add(2, cardPrefabs[2]); | |
cards.Add(3, cardPrefabs[3]); | |
fieldCards = new List<GameObject>(); | |
// カードを場に出す | |
foreach(var card in cards) | |
{ | |
Debug.Log(card.Key); | |
var go = Instantiate(card.Value); | |
fieldCards.Add(go); | |
if(card.Key > 0) | |
{ | |
go.transform.position = new Vector3( | |
fieldCards[card.Key-1].transform.position.x + 0.25f, | |
fieldCards[card.Key-1].transform.position.y, | |
fieldCards[card.Key-1].transform.position.z | |
); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment