Exemple #1
0
    // UI 오브젝트들을 초기화 시켜주는 메서드.
    private void UIInitalize()
    {
        Assert.IsNotNull(uiSystem);

        uiSystem.AttachUI(msgBox.gameObject);
        msgBox.ShowWithNoButton("Loading...");
    }
    private void Start()
    {
        Assert.IsNotNull(panelPrefab);

        panelPool = new GameObject[poolSize];

        for (var i = 0; i < poolSize; ++i)
        {
            panelPool[i]      = Instantiate(panelPrefab) as GameObject;
            panelPool[i].name = "Panel_" + i;
            panelPool[i].SetActive(false);

            uiSystem.AttachUI(panelPool[i]);
        }
    }
Exemple #3
0
    private void UIInitialize()
    {
        _uiSystem = FindObjectOfType <UISystem>();

        // 시간관련 초기화.
        _timeText = Instantiate(Resources.Load("GUI/TimeText") as GameObject).GetComponent <Text>();
        var timePosition = (new Vector3(Screen.width / 2, Screen.height * 0.95f, 0));

        timePosition.z = 0;
        _timeText.transform.position = timePosition;
        _uiSystem.AttachUI(_timeText.gameObject);

        _gameTimer = Instantiate(Resources.Load("Prefabs/GameTimer") as GameObject).GetComponent <GameTimer>();
        _gameTimer.SetText(_timeText);
        _gameTimer.OnTurnAutoEnd += OnTurnAutoEnd;

        // 플레이어 체력바 초기화.
        _playerHealthBar = Instantiate(Resources.Load("GUI/HorizontalBoxWithShadow") as GameObject);
        _playerHealthBar.transform.position = new Vector3(Screen.width * 0.2f, Screen.height * 0.88f, 0);
        _uiSystem.AttachUI(_playerHealthBar);

        _player.SetHealthBar(_playerHealthBar);

        // 적군 체력바 초기화.
        _enemyHealthBar = Instantiate(Resources.Load("GUI/HorizontalBoxWithShadow") as GameObject);
        _enemyHealthBar.transform.position = new Vector3(Screen.width * 0.8f, Screen.height * 0.88f, 0);
        _uiSystem.AttachUI(_enemyHealthBar);

        _enemy.SetHealthBar(_enemyHealthBar);

        // 플레이어 정보 초기화.
        _playerNameText = Instantiate(Resources.Load("GUI/PlayerNameText") as GameObject).GetComponent <Text>();
        _playerNameText.GetComponent <Text>().text = _dataContainer._playerId;
        _playerNameText.transform.position         = new Vector3(Screen.width * 0.128f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_playerNameText.gameObject);

        _playerText = Instantiate(Resources.Load("GUI/PlayerText") as GameObject).GetComponent <Text>();
        _uiSystem.AttachUI(_playerText.gameObject);

        _playerScoreText = Instantiate(Resources.Load("GUI/PlayerScoreText") as GameObject).GetComponent <Text>();
        _playerScoreText.GetComponent <Text>().text = "Wins : " + _dataContainer._playerWins.ToString() + "\n Loses : " + _dataContainer._playerLoses.ToString();
        _playerScoreText.transform.position         = new Vector3(Screen.width * 0.40f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_playerScoreText.gameObject);

        // 적군 정보 초기화.
        _enemyNameText = Instantiate(Resources.Load("GUI/EnemyNameText") as GameObject).GetComponent <Text>();
        _enemyNameText.GetComponent <Text>().text = _dataContainer._enemyId;
        _enemyNameText.transform.position         = new Vector3(Screen.width * 0.872f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_enemyNameText.gameObject);

        _enemyText = Instantiate(Resources.Load("GUI/PlayerText") as GameObject).GetComponent <Text>();
        _uiSystem.AttachUI(_enemyText.gameObject);

        _enemyScoreText = Instantiate(Resources.Load("GUI/EnemyScoreText") as GameObject).GetComponent <Text>();
        _enemyScoreText.GetComponent <Text>().text = _dataContainer._enemyWins.ToString() + " : Wins \n" + _dataContainer._enemyLoses.ToString() + " : Loses";
        _enemyScoreText.transform.position         = new Vector3(Screen.width * 0.60f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_enemyScoreText.gameObject);

        // 턴 텍스트 초기화.
        _turnText = Instantiate(Resources.Load("GUI/TurnText") as GameObject).GetComponent <Text>();
        _turnText.GetComponent <Text>().text = "PLAYER TURN";
        _turnText.transform.position         = new Vector3(Screen.width * 0.5f, Screen.height * 0f - 50f, 0);
        _uiSystem.AttachUI(_turnText.gameObject);

        // 게임 결과 텍스트 초기화.
        _endText         = Instantiate(Resources.Load("GUI/EndText") as GameObject).GetComponent <Text>();
        _endText.enabled = false;
        _uiSystem.AttachUI(_endText.gameObject);

        // 트윈 초기화.
        DOTween.Init(false, true, LogBehaviour.ErrorsOnly);
    }
Exemple #4
0
    /// <summary>
    /// UI 관련 오브젝트들의 초기화를 맡아주는 메서드,
    /// TODO :: 현재 메시지 박스가 IdInputField, PwInputField 보다 후 순위라서 이를 고쳐주어야 함.
    /// </summary>
    private void UIInitialize()
    {
        Assert.IsNotNull(uiSystem);

        #region INPUT FIELD INITIALIZE

        idInputField = Instantiate(Resources.Load("Prefabs/InputField") as GameObject).GetComponent <InputField>();
        Assert.IsNotNull(idInputField);

        if (idInputField != null)
        {
            idInputField.name = "Id Input Field";
            idInputField.onValueChanged.AddListener(delegate { OnIdValueChanged(idInputField.text); });

            idInputField.text = "Type Your ID...";

            var fieldPosition = new Vector3()
            {
                x = Screen.width * 0.5f,
                y = Screen.height * 0.39f,
                z = 0
            };

            idInputField.transform.position = fieldPosition;

            uiSystem.AttachUI(idInputField.gameObject);
        }

        pwInputField = Instantiate(Resources.Load("Prefabs/InputField") as GameObject).GetComponent <InputField>();
        Assert.IsNotNull(pwInputField);

        if (pwInputField != null)
        {
            pwInputField.name = "Pw Input Field";
            pwInputField.onValueChanged.AddListener(delegate { OnPwValueChanged(pwInputField.text); });

            pwInputField.text = "Type Your Password...";

            var fieldPosition = new Vector3()
            {
                x = Screen.width * 0.5f,
                y = Screen.height * 0.29f,
                z = 0
            };

            pwInputField.transform.position = fieldPosition;

            uiSystem.AttachUI(pwInputField.gameObject);
        }

        #endregion

        #region BUTTON FIELD INITIALIZE

        var loginButton = Instantiate(Resources.Load("Prefabs/Button") as GameObject).GetComponent <Button>();
        Assert.IsNotNull(loginButton);

        if (loginButton != null)
        {
            loginButton.name = "Login Button";
            loginButton.onClick.AddListener(OnLoginButtonClicked);

            var buttonText = loginButton.gameObject.GetComponentInChildren <Text>();
            Assert.IsNotNull(buttonText);
            buttonText.text = "LOGIN";

            var buttonPosition = new Vector3()
            {
                x = Screen.width * 0.5f,
                y = Screen.height * 0.15f,
                z = 0
            };

            loginButton.transform.position = buttonPosition;

            uiSystem.AttachUI(loginButton.gameObject);
        }

        #endregion

        #region MSG BOX INITIALIZE

        Assert.IsNotNull(msgBox);

        msgBox.Hide();

        #endregion
    }