Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Assets\NewBehavior.cs(34,29): error CS1002: ; expected

Discussion in 'Scripting' started by bboongbboongi, Aug 5, 2022.

  1. bboongbboongi

    bboongbboongi

    Joined:
    Aug 5, 2022
    Posts:
    2
    I was coding a game and after I wrote the 'if' part, it doesn't work

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

    public class NewBehavior : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {
    Debug.Log("Hello");


    //변수: 데이터를 메모리에 저장하는 장소


    int level = 10; //정수형 데이터
    float strength = 30.5f; //숫자형 데이터(소수점 포함)
    string playerName = "예원"; //문자열 데이터
    bool isFulLevel = false; //논리형 데이터(T/F)

    //그룹형 변수
    string[] monsters = { "이뚜쥬", "이꽁테" };
    int[] monsterLevel = new int[2];
    monsterLevel[0] = 20;
    monsterLevel[1] = 10;

    Debug.Log("작업실에 존재하는 몬스터의 레벨");
    Debug.Log(monsterLevel[0]);
    Debug.Log(monsterLevel[1]);

    List<string> items = new List<string>();
    items.Add("서브웨이");
    items.Add("물");
    items.Add("넷플릭스 보기")

    Debug.Log("가지고 있는 아이템");
    Debug.Log(items[0]);
    Debug.Log(items[1]);
    Debug.Log(items[2]);

    items.RemoveAt(0);

    Debug.Log("가지고 있는 아이템");
    Debug.Log(items[2]);


    //연산자
    int exp = 30000;

    exp = 30000 + 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 fulLevel = 450;
    isFulLevel = level == fulLevel; //==: 서로 같음
    Debug.Log("작가는 만렙입니까?" + isFulLevel);


    bool isEndTutorial = level > 30;
    Debug.Log("튜토리얼이 끝난 작가입니까?" + isEndTutorial);

    int health = 500;
    int mana = 300;
    bool isBadCondition = health <= 50 && mana <= 20; //&&: and. 두 값 모두 true일때만 true 출력
    //bool isBadCondtion = health <= 50 || mana <= 20; //||: or, shift+원화표시
    Debug.Log("작가의 상태가 나쁩니까?" + isBadCondition);

    string condition = isBadCondition ? "나쁨" : "좋음";
    //true : false
    Debug.Log("작가의 상태가 나쁩니까?" + condition);


    //4. 키워드
    //int float = 1; string name = List;

    //5. 조건문
    if (condition == "나쁨") {
    Debug.Log("작가의 상태가 나쁘니 아이템을 사용하세요.");
    }
    else {
    Debug.Log("작가의 상태가 좋습니다.");
    }

    if (isBadCondition && items[0] == "서브웨이") {
    items.RemoveAt(0);
    health += 30;
    Debug.Log("서브웨이를 먹었습니다.");
    }
    else if (isBadCondition && items[1] == "물") {
    items.RemoveAt(0);
    mana += 30;
    Debug.Log("물을 마셨습니다.");

    }
    }



    }
     
  2. bboongbboongi

    bboongbboongi

    Joined:
    Aug 5, 2022
    Posts:
    2
    Am I doing wrong? Help me to fix this :(