티스토리 뷰

#스테이지가 진행됨에 따라 유저가 획득하는 재화의 양이 증가되야한다

룸 클리어 후 (룸에서 모든 몬스터가 죽었을때) 보상상자가 생성되고
보상상자와 플레이어가 충돌 할 때 재화가 생성된다

 

난이도 별로 보상상자의 재화가치를 정의하고 데이터 테이블을 만들었다

보상상자는 Wood,Iron,Gold,Diamond 로 등급이 나뉘고 스테이지 마다 등장하는 등급이 달라진다(Diamond Chest는 보스 클리어 조건에 만 등장)

 

테이블을 적용할 스크립트를 만들고 데이터를 관리할 datamanger를 만들었다

datamanager에서는 key(step) 으로 value들을 찾고 반환하게 만들고 필요한 데이터들을 불러왔다

 

처음 기획 당시 룸의 난이도와 보스의 난이도를 별개로 기획했기 때문에 데이터 테이블을 만들때 혼동이 있었다.

보스의 난이도를 정의하기위해 stage key를 만들어 주었고 보상상자를 생성할 때 (bool)isBoss 와 stage 로 현재 보스의

난이도를 정의하였다.

 

# 재화가 생성되는 플로우

 유저가 있는 룸에 몬스터가 모두 죽었다면?

 

*MonsterGenerator

 -> portal Arrow 활성화 -> Chest 생성(bool값으로 보스인지 아닌지 판단), Chest에 Current Stage와 step 정의(Boss는 100,200,300,400 순으로 정의) 

#Boss가 죽었을때 bool값 true로 디스패치
#MonsterGenerator 에서 isBoss true / false 판단 후 Chest 만들기

 

 *NpcController

->player가 chet와 충돌 -> Chest에서 DropItem 생성(Equipment, Gold, Ether, Relic, Weapon 생성)

->상자의 포지션을 인자로 받은 메서드에서 Random.insideUnitSphere*radius를 이용하여 랜덤한 위치에 생성

#NpcController player와 충돌하면 Chest 생성

 private void MakeChset(Transform callPosition , bool isBoss = false) //boss
    {
        Debug.LogFormat("위치 : {0} , 보스방? : {1}", callPosition.position, isBoss);
        Transform chestPTrans = callPosition.transform.GetChildren()
            .Where(c => c.gameObject.tag == "ChestPoint")
            .Select(c => c.transform)
            .First();
        var setp = InfoManager.instance.dungeonInfo.currentStepInfo;
        var stageNum = InfoManager.instance.dungeonInfo.CurrentStageInfo;
        var go = default(GameObject);

        if (!isBoss)
        {    
            if(setp<3)
            {
                go = GameObject.Instantiate(this.WoodChest, chestPTrans);
                go.name = go.name.Replace("(Clone)", "");
                go.transform.localPosition = Vector2.zero;
            }
            else if (setp < 6)
            {
                go = GameObject.Instantiate(this.IronChest, chestPTrans);
                go.name = go.name.Replace("(Clone)", "");
                go.transform.localPosition = Vector2.zero;
            }
            else if(setp < 16)
            {
                go = GameObject.Instantiate(this.GoldChest, chestPTrans);
                go.name = go.name.Replace("(Clone)", "");
                go.transform.localPosition = Vector2.zero;
            }
            var comp = go.GetComponent<NPCController>();
            comp.stepNum = setp; //1~15 ==difficulty
            comp.stageNum = stageNum; //1,2,3,4 ==difficulty
            Debug.LogFormat("<color=red>Normal Stage:{0} ,step:{1}</color>", stageNum, setp);
        }
        else if(isBoss)
        {
            Debug.Log("BossChest!");
            go = GameObject.Instantiate(this.DiamondChest, chestPTrans);
            go.name = go.name.Replace("(Clone)","");
            go.transform.localPosition = Vector2.zero;

            var comp = go.GetComponent<NPCController>();
            comp.stepNum = stageNum * 100; //1~15 ==difficulty
            //comp.stageNum = ; //1,2,3,4 ==difficulty
            Debug.LogFormat("<color=red>Boss Stage:{0}</color>", comp.stepNum);
        }
    }

*DropItem

 ->player와 dropItem 충돌 -> Coin 또는 Ether 와 충돌한다면? Chest의 맴버로 넘겨받은 현재 stage와step을 기준으로 
 rewardGold / rewardEther 수급 (IncreaseDungeonGold / IncreaseEther) 

 ->Player UI 업데이트

    public void GetCoin() //data 연동 필요
    {
        
        var rewardGold = DataManager.Instance.GetRewardGold(this.stepNum);
        Debug.LogFormat("<color=yellow>gold : {0}</color>",rewardGold);
        InfoManager.instance.IncreaseDungeonGold(rewardGold);
        EventDispatcher.Instance.Dispatch(EventDispatcher.EventName.UICurrencyDirectorUpdateGoldUI);

        Destroy(this.gameObject);
    }

#Test (1Stage step / 1Stage Boss)

 

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함