Пример #1
0
 private void Awake()
 {
     if (instance != null)
     {
         return;
     }
     instance = this;
 }
Пример #2
0
    public void CreatePlayerList()
    {
        int i = 1;

        foreach (var pos in OnlyPositionList)
        {
            GameObject tmpPlayer = Instantiate(playerPrefab) as GameObject;

            tmpPlayer.transform.SetParent(canvas.transform, false);

            // GameObject canvas = tmpPlayer.transform.Find("Canvas").gameObject;

            GameObject playerTag = tmpPlayer.transform.Find("PlayerTag").gameObject;

            playerTag.transform.localPosition = new Vector3(0, 5, 0);

            Text playerTagText = playerTag.GetComponent <Text>();

            var playerNames = StartButtonScript.getPlayerDict();

            playerTagText.text = playerNames[i];

            var name = "player" + i;

            tmpPlayer.name = name;

            playerlist[i - 1] = tmpPlayer;

            var sr = playerlist[i - 1].AddComponent <SpriteRenderer>();

            sr.sprite = playerSprite[i - 1];

            sr.sortingOrder = 4;

            playerlist[i - 1].transform.position = GetDisplayPosition(pos.x, pos.y);

            playerPosTable.Add(playerlist[i - 1], new Vector2Int(pos.x, pos.y));
            i += 1;
        }
    }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        turnPlayerNum += 1;
        if (turnPlayerNum > totalPlayers)
        {
            turnPlayerNum = 1;
            roundNum     += 1;
        }
        // プレイヤーリストの取得
        playerDictionary = StartButtonScript.getPlayerDict();
        foreach (var pair in playerDictionary)
        {
            Debug.Log(pair.Key);
        }
        Text turnPlayerText = GetComponent <Text>();

        turnPlayerText.text = playerDictionary[turnPlayerNum];
        Text raunndoText = raunndoObject.GetComponent <Text>();

        raunndoText.text = roundNum.ToString();
        Debug.Log(totalPlayers);
    }
Пример #4
0
    // プレイヤーリストの作成と配置
    private void InitialCreatePlayerList()
    {
        for (int i = 1; i <= playerNum; i++)
        {
            GameObject tmpPlayer = Instantiate(playerPrefab) as GameObject;

            tmpPlayer.transform.SetParent(canvas.transform, false);

            // GameObject canvas = tmpPlayer.transform.Find("Canvas").gameObject;

            GameObject playerTag = tmpPlayer.transform.Find("PlayerTag").gameObject;

            Text playerTagText = playerTag.GetComponent <Text>();

            var rectTransform = playerTag.GetComponent <RectTransform>();

            var playerNames = StartButtonScript.getPlayerDict();

            playerTagText.text = playerNames[i];

            var name = "player" + i;

            tmpPlayer.name = name;

            playerlist[i - 1] = tmpPlayer;

            var sr = playerlist[i - 1].AddComponent <SpriteRenderer>();

            sr.sprite = playerSprite[i - 1];

            sr.sortingOrder = 4;
            int x = 0;
            int y = 0;
            int IsWithoutCover = 0;
            while (IsWithoutCover == 0)
            {
                x = Random.Range(0, columns);
                y = Random.Range(0, rows);

                int IsSamePair = 0;
                foreach (var pair in playerPosTable)
                {
                    if (pair.Value == new Vector2Int(x, y))
                    {
                        IsSamePair = 1;
                    }
                }
                if (IsSamePair == 0)
                {
                    IsWithoutCover = 1;
                }
            }
            playerlist[i - 1].transform.position = GetDisplayPosition(x, y);

            rectTransform.localPosition = GetNameTagDisplayPosition(x, y);

            playerPosTable.Add(playerlist[i - 1], new Vector2Int(x, y));

            OnlyPositionList.Add(new Vector2Int(x, y));
        }
        IsInitial = 0;
    }