//1. 변수
Debug.Log("Hello unity!");
int level= 5;
float strength = 15.5f;
string playerName = "나검사";
bool isFullLevel = false;
Debug.Log("용사의 이름은?");
Debug.Log(playerName);
Debug.Log("용사의 레벨은?");
Debug.Log(level);
Debug.Log("용사의 힘은?");
Debug.Log(strength);
Debug.Log("용사는 만렙인가?");
Debug.Log(isFullLevel);
//2. 그룹형 변수
string[] monsters = { "슬라임", "사막뱀", "악마" };
int[] monsterLevel = new int[3];
monsterLevel[0] = 1;
monsterLevel[1] = 6;
monsterLevel[2] = 20;
Debug.Log("맵에 존재하는 몬스터");
Debug.Log(monsters[0]);
Debug.Log(monsters[1]);
Debug.Log(monsters[2]);
Debug.Log("맵에 존재하는 몬스터 레벨");
Debug.Log(monsterLevel[0]);
Debug.Log(monsterLevel[1]);
Debug.Log(monsterLevel[2]);
//2-2.리스트
List<string> items = new List<string>();
items.Add("생명물약30");
items.Add("마나물약30");
items.RemoveAt(0);
Debug.Log("가지고 있는 아이템");
Debug.Log(items[0]);
Debug.Log(items[1]);
//3.연산자
int exp = 1500;
exp = 1500 + 320;
exp = exp - 10;
level = exp / 300;
strength = level * 3.1f;
Debug.Log("용사의 총 경험치는?");
Debug.Log(exp);
Debug.Log("용사의 레벨은?");
Debug.Log(level);
Debug.Log("용사의 힘은?");
Debug.Log(strength);
int nextExp = 300 - (exp % 300);
Debug.Log("다음 레벨까지 남은 경험치는?");
Debug.Log(nextExp);
string title = "전설의";
Debug.Log("용사의 이름은?");
Debug.Log(title + " " + playerName);
int fullLevel = 99;
isFullLevel = level == fullLevel;
Debug.Log("용사는 만렙입니까?" + isFullLevel);
bool isEndTutorial = level > 10;
Debug.Log("튜토리얼이 끝난 용사입니까?" + isEndTutorial);
int health = 30;
int mana = 25;
//bool isBadCondition = health <= 50 && mana <= 20;
bool isBadCondition = health <= 50 || mana <= 20;
Debug.Log("용사의 상태가 나쁩니까?" + isBadCondition);
string condition = isBadCondition ? "나쁨" : "좋음";
Debug.Log("용사의 상태가 나쁩니까?" + condition);
//4.키워드
//int float string bool new List
//5.조건문
if (condition == "나쁨")
{
Debug.Log("플레이어가 상태가 나쁘니 아이템을 사용하세요");
}
else
{
Debug.Log("플레이어 상태가 좋습니다.");
}
if (isBadCondition && items[0] == "생명물약30")
{
items.RemoveAt(0);
health += 30;
Debug.Log("생명표션30을 사용하였습니다.");
}
else if (isBadCondition && items[0] == "마나물약30")
{
items.RemoveAt(0);
mana += 30;
Debug.Log("마나포션30을 사용하였습니다.");
}
'방방곳곳' 카테고리의 다른 글
송리단길 여유롭게 즐길 수 있는 식당 - 인딕슬로우, 인도음식점 추천 (0) | 2022.06.12 |
---|---|
전시회 추천, 볼만한 전시회, 여의도 가볼만한 곳 추천 - 에릭 요한슨 사진전 (0) | 2022.06.05 |
왕십리 분위기 좋은 초밥집! 연어 튀김이 진짜 맛있다.. 연어 머리튀김...스시도쿠 리뷰 (0) | 2021.09.12 |
노란달 제과점 : 수유에 있는 수제과자점 한정된 수량과 만족스러운 맛 (0) | 2021.07.23 |
무더운 여름이 되면 생각나는 냉면 그 중에서 평양냉면 을지로 맛집 우래옥 (0) | 2021.07.11 |