Ejemplo n.º 1
0
    public MapInfo ActiveMapBridge(MapManager.EntranceType currMapEndType, MapManager.EntranceType endType, string parentMapTag)
    {
        for (int i = 0; i < entrances.Length; i++)
        {
            if (entrances[i].CompareTag(parentMapTag) == true)
            {
                int     selected = Random.Range(0, 3);
                MapInfo sender   = entrances[i].GetChild(selected).GetComponent <MapInfo>();
                sender.transform.parent.gameObject.SetActive(true);

                // entrances[i].Find("BackGround").SetParent(sender.transform);
                //entrances[i].GetChild(entrances[i].childCount - 1).SetParent(sender.transform);
                BackGrounds[i].SetParent(sender.transform);
                BackGrounds[i].localPosition = backGroundsLocalPosition;

                int index = (int)currMapEndType;
                startPortals[index].SetParent(sender.transform);
                startPortals[index].transform.localPosition = portalLocalPostions[index];
                startPortals[index].gameObject.SetActive(true);

                index = (int)sender.GetEndType();
                endPortals[index].SetParent(sender.transform);
                endPortals[index].transform.localPosition = portalLocalPostions[startPortals.Length + index];
                endPortals[index].gameObject.SetActive(true);

                startTileMap.transform.SetParent(sender.transform);
                startTileMap.transform.position = sender.transform.position;
                startTileMap.SetActive(true);

                return(sender);
            }
        }
        return(null);
    }
Ejemplo n.º 2
0
    IEnumerator CoroutineMoveMap()
    {
        WaitForFixedUpdate wait = new WaitForFixedUpdate();
        int allPassedMap        = 0;

        while (true)
        {
            if (gameOver == false)
            {
                if (currMap.tileMap.transform.localPosition.x < -currMap.tileMap.size.x * 1.1f)
                {
                    usedMap++;
                    allPassedMap++;
                    speedRivision = (speedRivision > speedMaxRivision) ? speedMaxRivision : speedRivision += speedRivisionAddValue;
                    speed         = defaultSpeed * speedRivision;

                    patternRivision = (patternRivision < patternRivisionMin) ? patternRivisionMin : patternRivision -= speedRivisionAddValue;

                    if (allPassedMap % scoreItemLevelPerPassedMap == 0)
                    {
                        GameManager.Instance.ScoreUpgrade();
                        scoreSprite = GameManager.Instance.GetCurrentScoreSprite();
                    }


                    // 마지막 맵이 사라지면서 부모 오브젝트도 비활성화 함
                    // 추가
                    currMap.gameObject.SetActive(false);

                    // 맵 전환 분기
                    if (gridRoots.Length == 1)
                    {
                        // Debug.Log("Map Ea is 1");
                    }
                    if (usedMap > tileMapInfos[selected].maps.Length - 1 && gridRoots.Length > 1)
                    {
                        //Debug.Log("Map Change !");
                        usedMap = -1;
                        int usedIndex = selected;
                        prevSelectedMap = usedIndex;
                        selected        = gridMapIndex[Random.Range(0, gridRoots.Length)];
                        ///Debug.Log("New Map index : " + selected);
                        gridMapIndex.Remove(selected);
                        gridMapIndex.Add(usedIndex);

                        //StartCoroutine(CorDisablePrevMap(nextMap.gameObject));

                        // 추가
                        isFinalMap = true;
                        // 추가
                        gridRoots[selected].SetActive(true);

                        // selected 된 맵 인덱스의 BGM 을 재생한다
                        PlayMusic(selected);
                    }

                    Vector3 newPos;

                    newPos   = nextMap.tileMap.transform.localPosition + nextMap.tileMap.size;
                    newPos.y = newPos.z = 0;

                    // 새 맵 활성화
                    // 마지막 맵이 아닌 경우
                    // 현재 맵 endType 추출
                    MapManager.EntranceType mapEndType = nextMap.GetEndType();
                    nextMapIndex.Clear();
                    for (int i = 0; i < tileMapInfos[selected].maps.Length; i++)
                    {
                        if (tileMapInfos[selected].maps[i].GetStartType() == mapEndType)
                        {
                            // 현재 진행 중인 맵 인덱스는 빼버림
                            if (tileMapInfos[selected].maps[i] != nextMap)
                            {
                                //Debug.Log("IN : " + i);
                                nextMapIndex.Add(i);
                            }
                            else
                            {
                                //Debug.Log("OUT : " + i);
                            }
                        }
                    }

                    currMap = nextMap;

                    if (isFinalMap == false)
                    {
                        nextMap = tileMapInfos[selected].maps[nextMapIndex[Random.Range(0, nextMapIndex.Count)]];

                        nextMap.transform.localPosition = newPos;
                        nextMap.gameObject.SetActive(true);
                        nextMap.SetItemLocate(scoreItems, scoreSprite);

                        currMapTransform = currMap.tileMap.transform;
                        nextMapTransform = nextMap.tileMap.transform;
                    }
                    else
                    {
                        nextMap = mapBridge.ActiveMapBridge(currMap.GetEndType(), currMap.GetEndType(), gridRoots[selected].tag);
                        nextMap.transform.localPosition = newPos;
                        nextMap.gameObject.SetActive(true);

                        currMapTransform = currMap.tileMap.transform;
                        nextMapTransform = nextMap.transform;

                        isFinalMap = false;

                        if (prevSelectedMap != selected)
                        {
                            //Debug.Log("NotSame : " + prevSelectedMap + " : " + selected);
                            StartCoroutine(CorDisablePrevMap(currMap.gameObject));
                            StartCoroutine(CorDisablePrevMap(nextMap.gameObject));
                        }
                        else
                        {
                            //Debug.Log("Same : " + prevSelectedMap + " : " + selected);
                        }
                    }
                }
                currMapTransform.Translate(Time.fixedDeltaTime * -1 * speed * speedRivision, 0, 0, Space.Self);

                nextMapTransform.Translate(Time.fixedDeltaTime * -1 * speed * speedRivision, 0, 0, Space.Self);

                //currMap.tileMap.gameObject.transform.
                //    Translate(Time.fixedDeltaTime * -1 * speed, 0, 0, Space.Self);

                //nextMap.tileMap.gameObject.transform.
                //    Translate(Time.fixedDeltaTime * -1 * speed, 0, 0, Space.Self);
            }
            yield return(wait);
        }
    }
Ejemplo n.º 3
0
    void Start()
    {
        tileMapInfos = new TileMapInfo[gridRoots.Length];

        // 타일맵 인포 삽입작업
        for (int i = 0; i < gridRoots.Length; i++)
        {
            tileMapInfos[i] = new TileMapInfo(gridRoots[i]);
            gridMapIndex.Add(i);
        }

        selected = gridMapIndex[Random.Range(0, gridRoots.Length)];
        // Debug
        // 레트로, 자연, 흑목, 수중, 동굴
        //selected = 0;
        prevSelectedMap = selected;

        // selected 된 맵 인덱스의 BGM 을 재생한다
        PlayMusic(selected);


        Vector3 newPos;

        // Ver 1.1
        //selectedMap = Random.Range(0, tileMapInfos[selected].maps.Length);
        //MapInfo info = tileMapInfos[selected].maps[selectedMap];

        // Ver 1.2
        selectedMap = Random.Range(0, tileMapInfos[selected].maps.Length);
        MapInfo info = mapBridge.ActiveMapBridge(EntranceType.MIDDLE, EntranceType.MIDDLE, tileMapInfos[selected].parent.tag);

        // 추가
        tileMapInfos[selected].parent.SetActive(true);

        info.transform.localPosition = new Vector3(3.5f, 0, 0);
        info.gameObject.SetActive(true);
        info.SetItemLocate(scoreItems, scoreSprite);
        //usedMap++;

        currMap          = info;
        currMapTransform = currMap.tileMap.transform;

        // 현재 맵 endType 추출
        MapManager.EntranceType mapEndType = info.GetEndType();
        nextMapIndex.Clear();
        for (int i = 0; i < tileMapInfos[selected].maps.Length; i++)
        {
            if (tileMapInfos[selected].maps[i].GetStartType() == mapEndType)
            {
                // 현재 진행 중인 맵 인덱스는 빼버림
                if (i != selectedMap)
                {
                    nextMapIndex.Add(i);
                }
            }
        }

        int selectedNextMap = nextMapIndex[Random.Range(0, nextMapIndex.Count)];



        newPos = tileMapInfos[selected].maps[selectedMap].tileMap.transform.localPosition +
                 tileMapInfos[selected].maps[selectedNextMap].tileMap.size;
        newPos.y = newPos.z = 0;

        tileMapInfos[selected].maps[selectedNextMap].tileMap.transform.localPosition = newPos;
        tileMapInfos[selected].maps[selectedNextMap].tileMap.gameObject.SetActive(true);
        nextMap = tileMapInfos[selected].maps[selectedNextMap];
        nextMap.SetItemLocate(scoreItems, scoreSprite);
        nextMapTransform = nextMap.tileMap.transform;
        usedMap++;

        if (!isStop)
        {
            coMoveMap = StartCoroutine(CoroutineMoveMap());
        }
    }