Unity的C#编程教程_24_Else-If条件语句
- 2020 年 8 月 9 日
- AI
- C/C++/C#
- 多重条件的判断
- 假设选择不同难度等级的游戏
- 选择之后弹出对应的难度提示
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour
{
public int easyLevel = 0;
public int mediumLevel = 1;
public int hardLevel = 2;
public int chooseLevel;
void Start()
{
if (chooseLevel == easyLevel)
{
Debug.Log("Easy level is runing!");
}
else if (chooseLevel == mediumLevel)
{
Debug.Log("Medium level is runing");
}
else if(chooseLevel == hardLevel)
{
Debug.Log("Hard level is runing!");
}
else
{
Debug.Log("You choose wrong level!");
}
}
void Update()
{
}
}