예제 #1
0
파일: C_INPUT.cs 프로젝트: mindonghwi/DIY
    public void TowerUpgrade()
    {
        if (m_cPlayer.getGoid() < m_cTowerUpgrade.getUpgradeCount() * 5)
        {
            return;
        }
        m_cPlayer.upgradeTower(m_cTowerUpgrade.getUpgradeCount());


        m_cTowerUpgrade.upgradeTowerAttack(m_goTowerHolder);
    }
예제 #2
0
파일: C_UI.cs 프로젝트: mindonghwi/DIY
    public void UpdateUi(C_PLAYER cPlayer, C_GAMECOIN cGameCoin, C_INPUT cInput)
    {
        m_txtGold.text      = cPlayer.getGoid().ToString();
        m_txtCoinCount.text = cPlayer.getCoin().ToString();
        m_txtHealth.text    = cPlayer.getHealth().ToString();

        m_txtCoinName.text       = cGameCoin.getCoinName();
        m_txtCoinFlutuation.text = cGameCoin.getFlutuatuion().ToString() + "%";
        m_txtCoinPrice.text      = cGameCoin.getCoinPrice().ToString();
        m_txtUpgradeTower.text   = cInput.getUpgradePrice().ToString();
    }
예제 #3
0
파일: C_GAMEMGR.cs 프로젝트: mindonghwi/DIY
    // Update is called once per frame
    void Update()
    {
        //////////////////////////////////////////////////////
        if (Application.platform == RuntimePlatform.Android)
        {
            if (Input.touchCount == 1)
            {
                Vector2 vecPos      = Input.GetTouch(0).position;            // 터치한 위치
                Vector3 vecTheTouch = new Vector3(vecPos.x, vecPos.y, 0.0f); // 변환 안하고 바로 Vector3로 받아도 되겠지.

                Ray        ray = Camera.main.ScreenPointToRay(vecTheTouch);  // 터치한 좌표 레이로 바꾸엉
                RaycastHit hit;                                              // 정보 저장할 구조체 만들고
                if (Physics.Raycast(ray, out hit, Mathf.Infinity))           // 레이저를 끝까지 쏴블자. 충돌 한넘이 있으면 return true다.
                {
                    if (Input.GetTouch(0).phase == TouchPhase.Began)         // 딱 처음 터치 할때 발생한다
                    {
                    }
                    else if (Input.GetTouch(0).phase == TouchPhase.Moved)    // 터치하고 움직이믄 발생한다.
                    {
                        // 또 할거 하고
                    }
                    else if (Input.GetTouch(0).phase == TouchPhase.Ended)    // 터치 따악 떼면 발생한다.
                    {
                        //합성
                        if (m_cInput.getIsMerge())
                        {
                            if (hit.transform.parent.parent == m_goTowerHolder.transform)
                            {
                                m_cMyTowerProc.upgradeTurret(hit, m_goTowerHolder, m_cLoadData, m_cInput);
                                //m_cMyProc.upgradeTurret(hit, m_goTowerHolder, m_cLoadTower, m_cInput);
                            }
                        }
                        //퍼즈
                        if (!m_cInput.getPause())
                        {
                            if (hit.transform.name == "StartHexagon")
                            {
                                m_cInput.startWave();
                            }
                        }
                        //생성
                        if (m_cPlayer.getGoid() >= 100)
                        {
                            if (m_cInput.getIsBuild())
                            {
                                if (hit.transform.parent == m_goMapHolder.transform)
                                {
                                    if (!hit.transform.gameObject.GetComponent <C_NODE>().m_goTower)
                                    {
                                        m_cPlayer.buyTower();
                                        m_cMyTowerProc.createTower(hit, m_goTowerHolder, m_cLoadData, m_cInput);
                                        //m_cMyProc.createTurret(hit, m_goTowerHolder, m_cLoadTower, m_cInput);
                                    }
                                }
                            }
                        }
                        if (m_cInput.getIsSell())
                        {
                            m_cPlayer.addGold(hit.transform.parent.gameObject.GetComponent <C_TOWER>().m_nLevel * 50);
                            m_cMyTowerProc.SellTower(hit);
                            m_cInput.offIsSell();
                        }

                        if (hit.transform.parent.parent == m_goTowerHolder.transform)
                        {
                            for (int i = 0; i < m_goTowerHolder.transform.childCount; i++)
                            {
                                if (hit.transform.parent != m_goTowerHolder.transform.GetChild(i))
                                {
                                    m_goTowerHolder.transform.GetChild(i).GetComponent <C_TOWERUI>().offUi();
                                }
                            }
                            m_cMyTowerProc.ActiveTowerUi(hit);
                        }
                    }
                }
            }


            if (Input.GetKeyDown(KeyCode.Escape))
            {
                m_goQuestionBox.GetComponent <C_QUESTIONMESSAGEBOX>().setQuestionBox();
                m_cInput.setPuase();
            }
        }
        else
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;


            if (Physics.Raycast(ray, out hit, 100))
            {
                if (hit.transform.parent.parent == m_goTowerHolder.transform)
                {
                    if (Input.GetMouseButtonDown(1))
                    {
                        hit.transform.parent.gameObject.GetComponent <C_TOWER>().m_goMyNode.GetComponent <C_NODE>().m_goTower = null;
                        Destroy(hit.transform.parent.gameObject);
                        m_cPlayer.addGold(50);
                    }
                    else if (Input.GetMouseButtonDown(0))
                    {
                        for (int i = 0; i < m_goTowerHolder.transform.childCount; i++)
                        {
                            if (hit.transform.parent != m_goTowerHolder.transform.GetChild(i))
                            {
                                m_goTowerHolder.transform.GetChild(i).GetComponent <C_TOWERUI>().offUi();
                            }
                        }
                        m_cMyTowerProc.ActiveTowerUi(hit);
                    }
                }
                if (m_cPlayer.getGoid() >= 100)
                {
                    if (m_cInput.getIsBuild())
                    {
                        if (hit.transform.parent == m_goMapHolder.transform)
                        {
                            if (Input.GetMouseButtonDown(0) && !hit.transform.gameObject.GetComponent <C_NODE>().m_goTower)
                            {
                                m_cPlayer.buyTower();
                                m_cMyTowerProc.createTower(hit, m_goTowerHolder, m_cLoadData, m_cInput);
                                //m_cMyProc.createTurret(hit, m_goTowerHolder, m_cLoadData.getLoadTower(), m_cInput);
                            }
                        }
                    }
                }
                if (m_cInput.getIsMerge())
                {
                    if (hit.transform.parent.parent == m_goTowerHolder.transform)
                    {
                        if (Input.GetMouseButtonDown(0))
                        {
                            m_cMyTowerProc.upgradeTurret(hit, m_goTowerHolder, m_cLoadData, m_cInput);
                            //m_cMyProc.upgradeTurret(hit, m_goTowerHolder, m_cLoadData.getLoadTower(), m_cInput);
                        }
                    }
                }
                if (m_cInput.getIsSell())
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        m_cPlayer.addGold(hit.transform.parent.gameObject.GetComponent <C_TOWER>().m_nLevel * 50);
                        m_cMyTowerProc.SellTower(hit);
                        m_cInput.offIsSell();
                    }
                }
                if (!m_cInput.getPause())
                {
                    if (hit.transform.name == "StartHexagon")
                    {
                        if (Input.GetMouseButtonDown(0))
                        {
                            m_cInput.startWave();
                        }
                    }
                }
            }
        }

        // If there are two touches on the device...


        m_cUi.UpdateUi(m_cPlayer, m_cGameCoin, m_cInput);
        m_cUi.updataWave(m_cStageMgr.getEnemyWave().GetComponent <C_ENEMYWAVE>());
        gameOver();
    }