Exemplo n.º 1
0
        /// <summary>
        /// 퀘스트 진행도를 갱신한다.(Accum) 의미없는 키는 자동으로 무시된다.
        /// (코드 수정시 CheckQuest_Set()함수도 동일하게 수정할 것. 바꿀부분은 복붙하면 빨간줄 그어짐
        /// </summary>
        public void CheckQuest_Accum(string requestKey, int acc)
        {
            bool isDirty = false;


            // 플레이어가 받고 있는 퀘스트 중에
            for (int i = 0; i < UserData.quests.Count; i++)
            {
                // 키에 맞는 퀘스트 정보를 불러온다.
                var questInfo = QuestDatabase.GetInfo(UserData.quests[i].key);

                // 퀘스트에 맞는 요구키가 있는지 찾는다.
                for (int j = 0; j < questInfo.requestKey.Length; j++)
                {
                    // 요구키와 동일한 키가 있다면 퀘스트 진행도 업데이트
                    if (questInfo.requestKey[j] == requestKey)
                    {
                        isDirty = true;
                        UserData.quests[i].progress[j] += acc;
                        this.onProgressChanged?.Invoke(UserData.quests[i].key);

                        KLog.Log(string.Format("<color=red>{0} Check Quest</color>", requestKey));
                    }
                }
            }

            // 데이터가 갱신되었으면 업데이트
            if (isDirty)
            {
                UserData.UpdateData();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 컨디션 업데이트
        /// </summary>
        /// <param name="dt"></param>
        public void Update(float dt)
        {
            /////////////////////////////////////////////////////////
            // 컨디션 업데이트
            for (int i = 0; i < this.conditions.Count; i++)
            {
                this.conditions[i].Update(dt);

                // 컨디션을 종료할 수 있으면
                if (this.conditions[i].IsEnd())
                {
                    KLog.Log(string.Format("Remove Condition. Unit: {0}, Condition: {1}", this.unit.unitKey, this.conditions[i].GetType()));

                    // 제거되는 컨디션
                    UnitCondition removeCondition = this.conditions[i].conditionType;

                    // 컨디션을 종료한다.
                    this.onRemoveCondition?.Invoke(this.conditions[i]);
                    this.conditions[i].Finish();
                    this.conditions.RemoveAt(i--);

                    TryRemoveEffect(removeCondition);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 던전을 클리어 했다.
        /// </summary>
        /// <param name="dungeonKey"></param>
        public static void ClearDungeon(string dungeonKey)
        {
            if (!UserData.clearedDungeon.Contains(dungeonKey))
            {
                UserData.clearedDungeon.Add(dungeonKey);
            }

            KLog.Log("Clear Dungeon. " + dungeonKey);
        }
Exemplo n.º 4
0
 void FixedUpdate()
 {
     duration += Time.fixedDeltaTime;
     if (duration > 1f)
     {
         duration = 0f;
         KLog.Log(KLogLevel.Debug, $"test success!");
     }
 }
Exemplo n.º 5
0
        private void Awake()
        {
            if (this.root == null)
            {
                KLog.Log("root is null", this);
            }

            // 선택지로 사용할 버튼들 캐싱 + 비활성화
            this.elements = this.root.GetComponentsInChildren <SelectionUI_Element>();
            InactiveAllElement();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 선택지는 최대 4개까지 지원한다.
        /// </summary>
        public void Init(SelectionData[] list, UnityAction <int> onComplete)
        {
            if (list.Length >= 4)
            {
                KLog.Log("선택지는 최대 4개까지 지원함");
            }

            InactiveAllElement();
            for (int i = 0; i < list.Length; i++)
            {
                this.elements[i].gameObject.SetActive(true);
                this.elements[i].Init(this, list[i]);
            }

            this.onComplete = onComplete;
        }
Exemplo n.º 7
0
        /// <summary>
        /// 컨디션 추가
        /// </summary>
        /// <param name="condition"></param>
        public void AddCondition(Condition condition)
        {
            // 다른 컨디션들에 따라 지금 등록되는 컨디션을 최종적용한다.
            for (int i = 0; i < this.conditions.Count; i++)
            {
                // 컨디션 종류가 같다면
                if (this.conditions[i].conditionType == condition.conditionType)
                {
                    // FIXME: 중복처리는 일단 보류. 일단 다 적용되도 문제는 없는거 같다.
                }
            }

            // 컨디션을 적용할 유닛 등록
            condition.unit = this.unit;

            // 컨디션 최종추가
            this.conditions.Add(condition);

            // 이펙트 추가
            string conditionTypeKey = condition.conditionType.ToString();

            // 관련 이펙트가 생성되지 않았고 && 이펙트가 지정되에 있을 때
            if (!this.effects.ContainsKey(conditionTypeKey) && !string.IsNullOrEmpty(condition.effectPath))
            {
                ParticleSystem ps = ObjectPoolManager.inst.Get <ParticleSystem>(condition.effectPath);
                ps.transform.SetParent(this.unit.transform, false);
                ps.transform.position      = condition.effectPosition;
                ps.transform.localRotation = Quaternion.identity;
                ps.transform.localScale    = Vector3.one * this.unit.radius * 2;
                ps.Play();

                this.effects.Add(conditionTypeKey, ps);
            }

            // 컨디션 초기화가 끝낫음을 알린다.
            condition.Start();

            // 컨디션 등록 델리게이트
            this.onAddCondition?.Invoke(condition);
            KLog.Log(string.Format("Add Condition. Unit: {0}, Condition: {1}", this.unit.unitKey, condition.GetType()));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 컨디션 강제 종료
        /// </summary>
        public void RemoveCondition(UnitCondition condition)
        {
            for (int i = 0; i < this.conditions.Count; i++)
            {
                if (this.conditions[i].conditionType == condition)
                {
                    KLog.Log(string.Format("Remove Condition. Unit: {0}, Condition: {1}", this.unit.unitKey, this.conditions[i].conditionType));

                    // 제거되는 컨디션
                    UnitCondition removeCondition = this.conditions[i].conditionType;

                    // 컨디션을 제거한다.
                    this.onRemoveCondition?.Invoke(this.conditions[i]);
                    this.conditions[i].Finish();
                    this.conditions.RemoveAt(i);

                    TryRemoveEffect(removeCondition);
                    break;
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 퀘스트를 추가한다.
 /// </summary>
 public void AddQuest(string questKey)
 {
     UserData.quests.Add(new QuestProgressInfo(questKey, new int[QuestDatabase.GetInfo(questKey).ifText.Length]));
     KLog.Log(string.Format("<color=red>{0} Add Quest</color>", questKey));
 }
Exemplo n.º 10
0
        /// <summary>
        /// 퀘스트를 클리어한다. 진행도 상관없이 클리어 하기 때문에
        /// 반드시 퀘스트 클리어 가능한지 여부를 확인할 것.
        /// </summary>
        /// <param name="questKey"></param>
        public void ClearQuest(string questKey)
        {
            // 현재 퀘스트 정보
            var currQuestInfo = QuestDatabase.GetInfo(questKey);

            // 아이템을 회수해야 하는경우 여기서 회수한다
            for (int i = 0; i < currQuestInfo.requestKey.Length; i++)
            {
                string chKey = currQuestInfo.requestKey[i];

                // 수집퀘스트키는 아이템을 회수
                if (chKey.Contains(QuestCheckKey.QuestKey_Collect_))
                {
                    UserManager.AccumItem(chKey.Substring(QuestCheckKey.QuestKey_Collect_.Length), -currQuestInfo.request[i]);
                }
            }

            // 관련 키를 언락한다.
            for (int i = 0; i < currQuestInfo.unlockKey.Length; i++)
            {
                UnlockManager.UnlockKey(currQuestInfo.unlockKey[i]);
            }

            // 퀘스트 보상을 준다
            for (int i = 0; i < currQuestInfo.rewardKey.Length; i++)
            {
                if (currQuestInfo.rewardKey[i] == "Coin")
                {
                    UserManager.AccumCoin(currQuestInfo.reward[i]);
                    StageMaster.current.playerController.hud.ViewEventText(string.Format("코인 획득 ({0})", currQuestInfo.reward[i]));
                }
                else
                {
                    UserManager.AccumItem(currQuestInfo.rewardKey[i], currQuestInfo.reward[i]);
                    StageMaster.current.playerController.hud.ViewEventText(string.Format("{0} 획득 ({1})", ItemDatabase.GetItemInfo(currQuestInfo.rewardKey[i]).itemName, currQuestInfo.reward[i]));
                }
            }

            // 퀘스트를 비운다.
            for (int i = 0; i < UserData.quests.Count; i++)
            {
                if (UserData.quests[i].key == questKey)
                {
                    UserData.quests.RemoveAt(i);
                }
            }

            // 퀘스트 클리어됨
            UserData.clearedQuest.Add(questKey);

            // 퀵뷰에 데이터가 남아있으면 삭제
            if (HasQuickView(questKey))
            {
                RemoveQuickView(questKey);
            }

            // 데이터 최종 적용
            UserData.UpdateData();

            this.onQuestClear?.Invoke(questKey);
            KLog.Log(string.Format("<color=red>{0} Clear Quest</color>", questKey));
        }