Beispiel #1
0
        public CUnitData GetUnitData(UnitType type, int nIdx)
        {
            if (!m_unitData[type].ContainsKey(nIdx))
            {
                return(null);
            }

            string name = m_unitData[type][nIdx];
            string path = "Scriptable/Unit/";

            switch (type)
            {
            case UnitType.Npc:
                path += "Npc/";
                break;

            case UnitType.Enemy:
                path += "Enemy/";
                break;

            case UnitType.Boss:
                path += "Boss/";
                break;
            }
            path += name;

            CUnitData enemy = Resources.Load <CUnitData>(path);

            return(enemy);
        }
    public void Init(int nQuestIndex)
    {
        m_questIndex = nQuestIndex;

        CQuestManager questMgr = CQuestManager.Inst;

        Data.QuestInfo?info = CDataManager.Inst.QuestContainer.GetQuest(m_questIndex);
        if (info == null)
        {
            Debug.LogError("Info is Missing");
            return;
        }

        m_questInfo = info.Value;

        if (m_questnameText != null)
        {
            m_questnameText.text = info.Value.questName;
        }

        if (m_questTargetIcon != null)
        {
            CUnitData unitData = CDataManager.Inst.UnitContainer.GetUnitData(m_questInfo.mainTargetType, m_questInfo.mainTargetIdx);

            if (unitData != null)
            {
                m_questTargetIcon.sprite = unitData.IconImage;
            }
        }
    }
Beispiel #3
0
    void UnitPoolCreate(Transform parent, UnitType type, Data.UnitContainer container)
    {
        m_unitPools[type] = new Dictionary <int, UnitPool>();

        for (int i = 0; i < container.GetUnitCount(type); i++)
        {
            CUnitData unitData = container.GetUnitData(type, i);
            if (unitData != null)
            {
                UnitPool pool = new UnitPool();
                pool.unitData      = unitData;
                pool.nBufferAmount = type != UnitType.Boss ? m_unitAmount:1;
                pool.pooledList    = new Stack <GameObject>();

                for (int j = 0; j < pool.nBufferAmount; j++)
                {
                    if (unitData.UnitPrefab == null)
                    {
                        break;
                    }
                    GameObject poolObj = Instantiate(unitData.UnitPrefab);
                    poolObj.name             = unitData.UnitPrefab.name;
                    poolObj.transform.parent = parent;
                    poolObj.SetActive(false);
                    pool.pooledList.Push(poolObj);
                }

                m_unitPools[type].Add(i, pool);
            }
        }
    }
Beispiel #4
0
    public void QuestReset()
    {
        m_checkCount  = 0;
        m_deathCount  = 0;
        m_deathLimit  = DeathCountBase;
        m_selectQuest = null;
        m_questTarget = null;

        CLoadingScene.LoadingScene("Lobby");
    }
Beispiel #5
0
    public void QuestSet(Data.QuestInfo questInfo)
    {
        if (m_selectQuest == null)
        {
            m_selectQuest = questInfo;
        }

        m_questName = questInfo.questName;

        m_questTarget = CDataManager.Inst.UnitContainer.GetUnitData(questInfo.mainTargetType, questInfo.mainTargetIdx);
    }
Beispiel #6
0
    public void QuestCheck(CUnitData targetData)
    {
        if (m_questTarget == null)
        {
            return;
        }

        if (m_questTarget != targetData)
        {
            return;
        }

        m_checkCount++;

        if (m_checkCount >= m_selectQuest.Value.mainTargetCount)
        {
            //TODO: 퀘스트 클리어 처리
            StartCoroutine(ReturnLobbyCoroutine("Quest Clear", 3f, 5f, 5f, 10f, MessageClipType.QuestClear));
        }
    }
Beispiel #7
0
    public void PooledObject(GameObject unitObj, CUnitData data, UnitType type, int nIdx)
    {
        UnitPool pool = m_unitPools[type][nIdx];

        if (pool == null)
        {
            Destroy(unitObj);
            return;
        }

        if (pool.pooledList.Count >= pool.nBufferAmount)
        {
            if (!m_canBeGrow)
            {
                Destroy(unitObj);
                return;
            }
        }

        unitObj.SetActive(false);
        unitObj.transform.parent = m_unitParent.transform;
        pool.pooledList.Push(unitObj);
    }
Beispiel #8
0
    public void Initialized(CSubLevel level, UnitType unitType, int nUnitIdx)
    {
        if (m_isInit)
        {
            return;
        }

        m_subLevel = level;

        CDataManager dataMgr = CDataManager.Inst;

        if (dataMgr != null)
        {
            CUnitData unit = dataMgr.UnitContainer.GetUnitData(unitType, nUnitIdx);

            if (unit != null)
            {
                m_spawnBase = unit;
            }
        }

        m_isInit = true;
        StartCoroutine(SpawnCoroutine());
    }
Beispiel #9
0
    IEnumerator StartGame()
    {
        m_stageUI = CStageUIManager.Inst;

        while (m_stageUI == null)
        {
            yield return(null);
        }

        if (m_stageUI != null)
        {
            while (m_stageUI.MessageUI == null)
            {
                yield return(null);
            }

            while (!m_stageUI.MessageUI.IsLoaded)
            {
                yield return(null);
            }
        }

        #region ObjectPoolWait

        while (CObjectPool.Inst == null)
        {
            yield return(null);
        }

        while (CObjectPool.Inst.IsInit == false)
        {
            yield return(null);
        }

        #endregion

        //TODO: 플레이어 생성(임시)
        while (CRootLevel.Inst == null)
        {
            yield return(null);
        }

        if (!IsGameStart)
        {
            #region BossRespon

            CUnitData targetData = m_questManager.QuestTarget;

            if (targetData != null)
            {
                if (m_questManager.SelectQuest != null && m_questManager.SelectQuest.Value.mainTargetType == UnitType.Boss)
                {
                    GameObject bossGo = CObjectPool.Inst.GetUnit(UnitType.Boss, targetData.Index);

                    if (bossGo == null)
                    {
                        IsGameStart = true;
                        yield break;
                    }

                    CBossUnit boss = bossGo.GetComponent <CBossUnit>();

                    if (boss != null)
                    {
                        boss.ResetUnit();

                        while (!CRootLevel.Inst.SubLevels.ContainsKey(targetData.StayLevel[0]))
                        {
                            yield return(null);
                        }

                        CSubLevel startLevel = CRootLevel.Inst.SubLevels[targetData.StayLevel[0]];

                        bossGo.transform.parent = null;
                        boss.ResetUnit();
                        boss.StayLevel            = startLevel;
                        bossGo.transform.position = startLevel.SpwanPoints == null ?
                                                    startLevel.transform.position + Vector3.up * 5f : startLevel.SpwanPoints[0].transform.position + Vector3.up * 2f;
                        bossGo.transform.rotation = Quaternion.identity;
                        bossGo.SetActive(true);

                        if (startLevel.SpwanPoints != null)
                        {
                            while (boss.Movement == null)
                            {
                                yield return(null);
                            }

                            boss.Movement.MoveWays = startLevel.SpwanPoints[0].GetWay(0);
                        }
                    }
                    else
                    {
                        Destroy(bossGo);
                        CLoadingScene.LoadingScene("Lobby");
                        yield break;
                    }
                }
            }
            #endregion
            IsGameStart = true;

            #region PlyaerCreateTemp

            GameObject playerPrefab = Resources.Load <GameObject>("Prefabs/Character/Player");
            GameObject startGo      = GameObject.FindWithTag("StartPoint");
            m_startPoint = startGo == null ? null : startGo.transform;
            GameObject player = Instantiate(playerPrefab, m_startPoint == null ? Vector3.zero : m_startPoint.position, Quaternion.identity);
            player.name = playerPrefab.name;

            #endregion
        }

        yield return(null);

        Data.QuestInfo?questInfo = m_questManager.SelectQuest;

        if (questInfo != null)
        {
            m_stageUI.MessageUI.ShowMainMessage(questInfo.Value.areaName, 3f, new Color(0.8f, 0.5f, 0f, 0.5f), MessageClipType.QuestStart);
            yield return(new WaitForSeconds(3f));

            m_stageUI.MessageUI.ShowSubMessage(questInfo.Value.questName, 3f);
            yield return(null);
        }
        else
        {
            m_stageUI.MessageUI.ShowSubMessage("Quest Start", 3f);
            yield return(null);
        }
    }