'전체 글'에 해당되는 글 95건

  1. 2020.03.26 SVN Conflict
  2. 2020.03.18 BOJ 14681 - 사분면 고르기
  3. 2020.02.27 Event Capturing
  4. 2020.02.27 2020. 2. 27 특성 창 기능 구현 (진행중)
  5. 2020.02.26 2020. 2. 26 특성 창 기능 구현 (진행중)
  6. 2020.02.18 PersistentDataPath

SVN Conflict

Portfolio/Diary 2020. 3. 26. 19:48

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIPage_shop_main : MonoBehaviour
{
    public UILabel lb_userGold;
    public int userGold;
    public UIPage_shop_buttons buttons;
    public UIPage_shop_pannels pannels;
    public UIPage_shop_popup_purchaseItem ui_popup_purchaseItem;


    private void Awake()
    {
        GetUserGoldInfo();
        if(UIScean_lobby_main.instance != null)
        {
            userGold = UIScean_lobby_main.instance.userGold;
            lb_userGold.text = userGold.ToString();
        }

        Data_Loader.GetInstance().GetSkillDataById(1);
        if(UIScean_lobby_main.instance != null)
        {
            userGold = UIScean_lobby_main.instance.userGold;
            lb_userGold.text = userGold.ToString();
        }

    }
    void Start()
    {
        buttons.btnAircrafts.onClick.Add(new EventDelegate(() =>
        {
            pannels.panAircrafts.gameObject.SetActive(true);
            pannels.panParts.gameObject.SetActive(false);
        }));

        buttons.btnParts.onClick.Add(new EventDelegate(() =>
        {
            pannels.panParts.gameObject.SetActive(true);
            pannels.panAircrafts.gameObject.SetActive(false);

        }));

        buttons.btnAlliances.onClick.Add(new EventDelegate(() =>
        {
            pannels.panAircrafts.gameObject.SetActive(false);
            pannels.panParts.gameObject.SetActive(false);
        }));

        buttons.btnClose.onClick.Add(new EventDelegate(() =>
        {
            this.gameObject.SetActive(false);
            UIScean_lobby_main.instance.userGold = this.userGold;
            UIScean_lobby_main.instance.UIpages.uiPage_lobby_main.gameObject.SetActive(true);
        }));

        UIPage_shop_popup_purchaseItem.changeInUserPropertiesCall = () =>
        {
            GetUserGoldInfo();
        };
    }

    public void GetUserGoldInfo()
    {
        userGold = UserInfo_Manager.GetInstance().GetProperties(eUserProperties.gold);
        lb_userGold.text = userGold.ToString();
    }
}

:

BOJ 14681 - 사분면 고르기

Console/Algorithm 2020. 3. 18. 19:59
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
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace BOJ_11399
{  
    class BOJ14681
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int y = int.Parse(Console.ReadLine());
 
            if (x > 0)
            {
                if(y > 0)
                {
                    Console.WriteLine(1);
                }
                else
                {
                    Console.WriteLine(4);
                }
            }
            else if (x < 0)
            {
                if(y > 0)
                {
                    Console.WriteLine(2);
                }
                else
                {
                    Console.WriteLine(3);                    
                }
            }
        }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

'Console > Algorithm' 카테고리의 다른 글

BOJ 2920  (0) 2019.11.05
BOJ 10871  (0) 2019.11.04
BOJ Q11654 - 아스키 코드  (0) 2019.09.30
백준 Q2438 - 별찍기  (0) 2019.09.30
백준 못푼문제 - 빠른 A+B  (0) 2019.09.30
:

Event Capturing

Portfolio/Problems 2020. 2. 27. 20:05

같은 기능을 가진 여러개의 버튼이 있을 때, 반복문을 사용하여 이벤트를 추가할 수 있었다.

분명히 예전에 잠깐 배운 내용인데 따로 기록을 하지않아 한시간 정도 헤멘거 같다.

 

원본 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
for(int i = 0; i < arrBtns.Length; i++)
        {          
            arrBtns[i].onClick.Add(new EventDelegate(() =>
            {
               GetPannelInfo(i);
                uiPopup_masteryInfo.gameObject.SetActive(true);
                if (listMasteryInfo[i].is_activated)
                {
                    uiPopup_masteryInfo.btn_setActive.gameObject.SetActive(false);
                    uiPopup_masteryInfo.btn_setInactive.gameObject.SetActive(true);
                }
                else
                {
                    uiPopup_masteryInfo.btn_setActive.gameObject.SetActive(true);
                    uiPopup_masteryInfo.btn_setInactive.gameObject.SetActive(false);
                }
            }));
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

위 코드로 실행을 했을 때 OutOfRangeException 에러가 났다. 이론적으론 될거같았는데.. 에러가 나는 정확한 원인은 리서치를 해봐야 될것 같다.

 

수정한 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
for(int i = 0; i < arrBtns.Length; i++)
        {
            int index = i;
            arrBtns[i].onClick.Add(new EventDelegate(() =>
            {
                GetPannelInfo(index);
                uiPopup_masteryInfo.gameObject.SetActive(true);
                if (listMasteryInfo[index].is_activated)
                {
                    uiPopup_masteryInfo.btn_setActive.gameObject.SetActive(false);
                    uiPopup_masteryInfo.btn_setInactive.gameObject.SetActive(true);
                }
                else
                {
                    uiPopup_masteryInfo.btn_setActive.gameObject.SetActive(true);
                    uiPopup_masteryInfo.btn_setInactive.gameObject.SetActive(false);
                }
            }));
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

계속 변하는 int i의 값을 int형 변수 index에 받아서 i값을 호출하던 부분을 모두 index로 변경하 후 실행하니 에러가 발생하지 않았다.

'Portfolio > Problems' 카테고리의 다른 글

File.WriteAllText - Access denied  (0) 2020.02.18
:

2020. 2. 27 특성 창 기능 구현 (진행중)

Portfolio/Diary 2020. 2. 27. 19:57

어제에 이어 특성창의 기능을 구현하였다.

오늘 구현한 것은 버튼의 상태에 따라 서로 다른 색을 입히는 것. 유저가 버튼의 색을 통해 버튼에 연계된 특성의 활성화/ 비활성화 / 활성화 가능 여부를 쉽게 구분할 수 있도록 하는것이 목적이다.

 

 

특성트리의 기본값(default) 상태이다. 아직 아무 특성도 활성화 되지 않았으므로 현재 활성화 할 수 있는 1st Depth의 버튼 두개가 파란색인것을 확인할 수 있다.

 

 

1번특성을 활성화 시켜보았다. 활성화 시킨 특성의 버튼의 색이 초록색으로 변하는것을 확인 할 수 있었다. 한 depth에 하나의 특성만 활성화 할 수 있는 시스템이기에 같은 depth의 다른 버튼은 회색으로 처리하였다. collider를 적용하지 않아 버튼을 클릭하여 특성을 활성화 할 수 있고, 이 경우 기존에 활성화 시켰던 같은 depth의 버튼이 회색으로 변한다. 

 

추가 사항

특성 팝업창의 버튼을 특성 활성화 여부에 따라 무조건 하나만 활성화되도록 변경하였다. (특성 비활성화 중인경우 활성화 버튼만 출력, 특성 활성화 중인 경우 비활성화 버튼만 출력)

 

'Portfolio > Diary' 카테고리의 다른 글

SVN Conflict  (0) 2020.03.26
2020. 2. 26 특성 창 기능 구현 (진행중)  (0) 2020.02.26
2020 - 02 - 18] Data load&save  (0) 2020.02.18
:

2020. 2. 26 특성 창 기능 구현 (진행중)

Portfolio/Diary 2020. 2. 26. 19:58

특성창의 기능을 구현하고 있다. 사진은 특성트리의 초기상태. 트리 가장 최상단 depth에 속한 특성 두개에 연계된 버튼만 활성화 되어있다.
활성화 된 버튼을 클릭하면 팝업창이 등장하며  선택한 특성에 대한 보다 자세한 설명과 함께 특성의 활성화 여부를 선택할 수 있다.
Set Active 버튼을 클릭하면 선택했던 특성이 활성화되고 다음 depth에 속한 버튼들이 활성화 된다.
이미 활성화 한 특성은 Set Inactve버튼을 클릭하여 비활성화 할 수 있다. 이 때 비활성화한 특성의 상위 depth에 속한 특성들은 모두 비활성화되며 소모된 재화의 수량을 파악하여 유저에게 반환한다.

 

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
   
    private void GetPannelInfo(int id)
    {
        uiPopup_masteryInfo.lb_masteryName.text = listMasteryInfo[id].mastery_name;
        uiPopup_masteryInfo.lb_masteryType.text = listMasteryInfo[id].mastery_type.ToString();
        uiPopup_masteryInfo.lb_masteryDescription.text = listMasteryInfo[id].description;
        uiPopup_masteryInfo.id = listMasteryInfo[id].mastery_id;        
    }
 
    private int GetActivatedDepth()
    {
        int count = 0//유저가 찍은 특성의 Depth를 구한다.
        for (int i = 0; i < arrAttDepthCondition.Length; i++)
        {
            if (arrAttDepthCondition[i] == true)
            {
                count++;
            }
        }
        return count;
    }
    private int GetOrdersUsed() //현재 활성화 된 모든 특성을 찍기 위해 투자한 훈장 갯수를 구한다.
    {
        int count = GetActivatedDepth();
        int orderUsed = 0;
        switch (count) 
        {
            case 1:
                {
                    orderUsed = 3;
                    break;
                }
            case 2:
                {
                    orderUsed = 9;
                    break;
                }
            case 3:
                {
                    orderUsed = 18;
                    break;
                }
            case 4:
                {
                    orderUsed = 27;
                    break;
                }
            case 5:
                {
                    orderUsed = 42;
                    break;
                }
        }
        return orderUsed;
    }
 
    private int GetOrdersUsed(int depth) //선택된 특성을 찍기까지 투자한 훈장 갯수를 구한다.
    {
        int count = depth;
        int orderUsed = 0;
        switch (count)
        {
            case 1:
                {
                    orderUsed = 3;
                    break;
                }
            case 2:
                {
                    orderUsed = 9;
                    break;
                }
            case 3:
                {
                    orderUsed = 18;
                    break;
                }
            case 4:
                {
                    orderUsed = 27;
                    break;
                }
            case 5:
                {
                    orderUsed = 42;
                    break;
                }
        }
        return orderUsed;
    }
 
    //유저가 비활성화 하고자하는 특성의 Depth를 받아 반환할 값을 구한다.        
    private int GetOrdersCountToReturn(int depth)
    {
        int output = GetOrdersUsed() - GetOrdersUsed(depth);
        return output;
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

반환값 구하는 로직 짜는데 한시간이 걸렸다...  머리가 너무 안돌아간다 ㅠㅠㅠㅠ

'Portfolio > Diary' 카테고리의 다른 글

SVN Conflict  (0) 2020.03.26
2020. 2. 27 특성 창 기능 구현 (진행중)  (0) 2020.02.27
2020 - 02 - 18] Data load&save  (0) 2020.02.18
:

PersistentDataPath

Console/API 2020. 2. 18. 17:14

*읽기전용. 게임 플레이 중 변하는 값을 안전하게 저장하기 위한 저장 경로 값(string)

 

'Console > API' 카테고리의 다른 글

for문 (반복문)  (0) 2019.09.24
Bool 논리 OR 연산자 ( || )  (0) 2019.09.24
Bool 논리 AND 연산자 (&&)  (0) 2019.09.24
Console.ForegroundColor Property  (0) 2019.09.23
Int.Parse Method  (0) 2019.09.23
: